Comments (1)
Here is an example:
using BilevelHeuristics
# upper-level objective function
function F(x, y)
F1 = y[1] - x[1] # objective function 1
F2 = y[2] # objective function 2
G1 = -1.0 - sum(y) # G(x,y) <= 0 is feasible
H1 = 0.0 # equality constraint
Fxy = [F1, F2]
Gxy = [G1]
Hxy = [H1]
return Fxy, Gxy, Hxy
end
# lower-level objective function
function f(x, y)
f1 = y[1] # objective function 1
f2 = y[2] # objective function 2
g1 = sum(y.^2) - x[1]^2 # g(x,y) <= 0 is feasible
h1 = 0.0 # equality constraint
fxy = [f1, f2]
gxy = [g1]
hxy = [h1]
return fxy, gxy, hxy
end
# boundaries by cols
bounds_ul = Matrix([0.0 1]')
bounds_ll = [-1.0 -1.0; 1.0 1.0]
# general options (settings)
options_ul = Options(iterations = 40, f_calls_limit=Inf, seed=1) # upper level
options_ll = Options(iterations = 40, f_calls_limit=Inf) # lower level
# Optimizer for each level
nsga2_ul = NSGA2(N = 400, p_m = 0.1, η_m = 20, η_cr = 15, p_cr = 0.9)
nsga2_ll = NSGA2(N = 40, p_m = 0.1, η_m = 20, η_cr = 15, p_cr = 0.9)
blemo = BLEMO(;ul = nsga2_ul, ll = nsga2_ll, options_ul, options_ll)
results = optimize(F, f, bounds_ul, bounds_ll, blemo);
# Get values saved in the archive
A_ul = map(s -> s[1], blemo.parameters.archive) # upper level
A_ll = map(s -> s[2], blemo.parameters.archive) # corresponding lower level
# get objective function values
Fxy = fvals(A_ul)
fxy = fvals(A_ll)
X = positions(A_ul)
Y = positions(A_ll)
You can save this code into test_blemo.jl
and execute it in the Julia command line using include("test_blemo.jl
")`
See here for more details.
from bilevelheuristics.jl.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bilevelheuristics.jl.