API References
Metaheuristics.optimize — Function optimize(
f::Function, # objective function
search_space,
method::AbstractAlgorithm = ECA();
logger::Function = (status) -> nothing,
)Minimize a n-dimensional function f with domain search_space (2×n matrix) using method = ECA() by default.
Example
Minimize f(x) = Σx² where x ∈ [-10, 10]³.
Solution:
julia> f(x) = sum(x.^2)
f (generic function with 1 method)
julia> bounds = [ -10.0 -10 -10; # lower bounds
10.0 10 10 ] # upper bounds
2×3 Array{Float64,2}:
-10.0 -10.0 -10.0
10.0 10.0 10.0
julia> result = optimize(f, bounds)
+=========== RESULT ==========+
iteration: 1429
minimum: 2.5354499999999998e-222
minimizer: [-1.5135301653303966e-111, 3.8688354844737692e-112, 3.082095708730726e-112]
f calls: 29989
total time: 0.1543 s
+============================+optimize(F, f, bounds_ul, bounds_ll, method = BCA(); logger = (status) -> nothing)Approximate an optimal solution for the bilevel optimization problem x ∈ argmin F(x, y) with x ∈ bounds_ul subject to y ∈ argmin{f(x,y) : y ∈ bounds_ll}.
Parameters
Fupper-level objective function.flower-level objective function.bounds_ul, bounds_llupper and lower level boundaries (2×n matrices), respectively.loggeris a functions called at the end of each iteration.
Example
julia> F(x, y) = sum(x.^2) + sum(y.^2)
F (generic function with 1 method)
julia> f(x, y) = sum((x - y).^2) + y[1]^2
f (generic function with 1 method)
julia> bounds_ul = bounds_ll = [-ones(5)'; ones(5)']
2×5 Matrix{Float64}:
-1.0 -1.0 -1.0 -1.0 -1.0
1.0 1.0 1.0 1.0 1.0
julia> res = optimize(F, f, bounds_ul, bounds_ll)
+=========== RESULT ==========+
iteration: 108
minimum:
F: 7.68483e-08
f: 3.96871e-09
minimizer:
x: [1.0283390421119262e-5, -0.00017833559080058394, -1.612275010196171e-5, 0.00012064585960330227, 4.38964383738248e-5]
y: [1.154609166391327e-5, -0.0001300400306798623, 1.1811981430188257e-6, 8.868498295184257e-5, 5.732849695863675e-5]
F calls: 2503
f calls: 5044647
Message: Stopped due UL function evaluations limitations.
total time: 21.4550 s
+============================+BilevelHeuristics.BLInformation — TypeBLInformation(ul, ll)BLInformation stores information Information about problems at each level (upper and lower level).
BilevelHeuristics.BLOptions — TypeBLOptions(ul, ll)BLOptions stores common settings Options for metaheuristics at each level (upper and lower level).
BilevelHeuristics.get_ll_population — Functionget_ll_population(population)Return the lower level solutions.
BilevelHeuristics.get_ul_population — Functionget_ul_population(population)Return the upper level solutions.
BilevelHeuristics.ulvector — Functionulvector(A)Get upper-level decision vector.
BilevelHeuristics.llvector — Functionllvector(A)Get lower-level decision vector.
BilevelHeuristics.ulfval — Functionulfval(A)Get upper-level function value.
BilevelHeuristics.llfval — Functionllfval(A)Get lower-level function value.
BilevelHeuristics.ulfvals — Functionulfvals(pop)Get upper-level function values from population.
BilevelHeuristics.llfvals — Functionllfvals(pop)Get lower-level function values from population.
BilevelHeuristics.ulgvals — Functionulgvals(pop)Get upper-level inequality constraints.
BilevelHeuristics.llgvals — Functionllgvals(pop)Get lower-level inequality constraints.
BilevelHeuristics.ulhvals — Functionulhvals(pop)Get upper-level equality constraints.
BilevelHeuristics.llhvals — Functionllhvals(pop)Get lower-level equality constraints.
BilevelHeuristics.ulpositions — Functionulpositions(population)Get upper-level decision vectors from population.
BilevelHeuristics.llpositions — Functionllpositions(population)Get lower-level decision vectors from population.
BilevelHeuristics.is_pseudo_feasible — Functionis_pseudo_feasible(A, B, δ1, δ2, ε1, ε2)Check whether A is a pseudo-feasible solution respect to B.