Skip to content

Commit

Permalink
update docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
jmejia8 committed Mar 5, 2024
1 parent eb59258 commit 23fa1b3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/src/problems.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Test Problems Algorithms

Bilevel optimization involves optimizing two interrelated optimization tasks, where one problem (the upper level) depends on optimal solutions of another at the lower level. This part presents test problems for bilevel optimization, including single and multi-objective scenarios.


```@docs
TestProblems.get_problem
```

39 changes: 39 additions & 0 deletions src/TestProblems/TestProblems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,45 @@ include("DS/DS.jl")
include("TP/TP.jl")
include("RealWorld/RealWorld.jl")

"""
get_problem(problem)
Return `F, f, bounds_ul, bounds_ll, Ψ, o` where
- `F` is the upper-level objective function.
- `f` is the lower-level objective function.
- `bounds_ul` is the upper-level bounds.
- `bounds_ll` is the lower-level bounds.
- `Ψ`-mapping that receives upper-level decision vector and return a Matrix containing lower-level optimal solutions.
- `o` contain a sampled optimal solutions.
# Example
```julia
using BilevelHeuristics
using DelimitedFiles
F, f, bounds_ul, bounds_ll, _ = TestProblems.get_problem("TP1")
algorithm = SMS_MOBO(;
ul = SMS_EMOA(;N = 100), # upper level optimizer
ll = NSGA2(;N = 50), # lower level optimizer
ul_offsprings = 10,
options_ul = Options(iterations = 100, f_calls_limit=Inf),
options_ll = Options(iterations = 50, f_calls_limit=Inf)
)
res = optimize(F, f, bounds_ul, bounds_ll, algorithm)
final_archive = algorithm.parameters.archive
final_archive[1][1] # upper level (solution #1)
final_archive[1][2] # lower level (solution #1)
ul_front = fvals([sol[1] for sol in final_archive])
writedlm("data.csv", ul_front, ',')
```
"""
function get_problem(problem::AbstractString)
if problem[1:2] == "TP"
return TP.get_problem(parse(Int, problem[3:end]))
Expand Down

0 comments on commit 23fa1b3

Please sign in to comment.