Skip to content

jmejia8/BiPlots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BiPlots

Plot results of Bilevel package.

Example

Import necessary packages:

using Bilevel
using BiPlots

Definition of the bilevel optimization problem:

# minimize
F(x,y) = sum((x + y - sin.(4π*x)).^2)

# subject to: y in arg min f(x,y) with
f(x,y) = sum((sin.(4π*x) - y).^2)

Configure the BCA method:

options = Options(F_calls_limit=1000,
                    f_calls_limit=Int(1e6),
                    debug=false,store_convergence=false)

BCA = BCAOperators.BCAFW(N =30)

method = Algorithm(BCA;
                    initialize! = BCAOperators.initialize!,
                    update_state! = BCAOperators.update_state!,
                    lower_level_optimizer = BCAOperators.lower_level_optimizer,
                    is_better = BCAOperators.is_better,
                    stop_criteria = BCAOperators.stop_criteria,
                    options = options)

Optimize and get results:

r = optimize(F,
            f,
            [-1 -1; 1 1.0],
            [-1 -1; 1 1.0],
            method
    )

Convergence animation:

a = animateConvergence(Array{State{Int64}}(r.convergence); legend=false) 
gif(a, "tmp1.gif")

animateConvergence

Population dynamics:

a = @animate for t=1:length(r.convergence)
    scatter(r.convergence[t].population; legend=false, title="iter: $t")
end
gif(a, "tmp2.gif")

population dynamics

About

Plots of Bilevel results

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages