diff --git a/docs/src/tutorials/ensemble.md b/docs/src/tutorials/ensemble.md index 0b7459bf1..712d96841 100644 --- a/docs/src/tutorials/ensemble.md +++ b/docs/src/tutorials/ensemble.md @@ -27,14 +27,14 @@ This results is compared to a multistart approach with 4 random initial points: ```@example ensemble x0s = [x0, x0 .+ rand(2), x0 .+ rand(2), x0 .+ rand(2)] -function prob_func(prob, i, repeat) - remake(prob, u0 = x0s[i]) +function prob_func(prob, ctx) + remake(prob, u0 = x0s[ctx.sim_id]) end ensembleprob = EnsembleProblem(prob; prob_func) @time sol = solve(ensembleprob, OptimizationOptimJL.BFGS(), EnsembleThreads(), trajectories = 4, maxiters = 5) -@show findmin(i -> sol[i].objective, 1:4)[1] +@show minimum(s.objective for s in sol.u) ``` 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. diff --git a/docs/src/tutorials/remakecomposition.md b/docs/src/tutorials/remakecomposition.md index bc41b7321..fe9e1784b 100644 --- a/docs/src/tutorials/remakecomposition.md +++ b/docs/src/tutorials/remakecomposition.md @@ -46,7 +46,7 @@ res1 = solve(prob, BBO_adaptive_de_rand_1_bin(), maxiters = 4000) This is a good start can we converge to the global optimum? ```@example polyalg -prob = remake(prob, u0 = res1.minimizer) +prob = remake(prob, u0 = res1.u) res2 = solve(prob, OptimizationLBFGSB.LBFGSB(), maxiters = 100) @show res2.objective