Skip to content

Commit 42fd2df

Browse files
Fix stale docs examples (#1246)
Update the ensemble tutorial for the current EnsembleContext callback API and use the public solution fields exposed by current OptimizationSolution and EnsembleSolution values. Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
1 parent 1145f77 commit 42fd2df

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

docs/src/tutorials/ensemble.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ This results is compared to a multistart approach with 4 random initial points:
2727

2828
```@example ensemble
2929
x0s = [x0, x0 .+ rand(2), x0 .+ rand(2), x0 .+ rand(2)]
30-
function prob_func(prob, i, repeat)
31-
remake(prob, u0 = x0s[i])
30+
function prob_func(prob, ctx)
31+
remake(prob, u0 = x0s[ctx.sim_id])
3232
end
3333
3434
ensembleprob = EnsembleProblem(prob; prob_func)
3535
@time sol = solve(ensembleprob, OptimizationOptimJL.BFGS(),
3636
EnsembleThreads(), trajectories = 4, maxiters = 5)
37-
@show findmin(i -> sol[i].objective, 1:4)[1]
37+
@show minimum(s.objective for s in sol.u)
3838
```
3939

4040
With the same number of iterations (5) we get a much lower (1/100th) objective value by using multiple initial points. The initialization strategy used here was a pretty trivial one but approaches based on Quasi-Monte Carlo sampling should be typically more effective.

docs/src/tutorials/remakecomposition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ res1 = solve(prob, BBO_adaptive_de_rand_1_bin(), maxiters = 4000)
4646
This is a good start can we converge to the global optimum?
4747

4848
```@example polyalg
49-
prob = remake(prob, u0 = res1.minimizer)
49+
prob = remake(prob, u0 = res1.u)
5050
res2 = solve(prob, OptimizationLBFGSB.LBFGSB(), maxiters = 100)
5151
5252
@show res2.objective

0 commit comments

Comments
 (0)