Skip to content

Commit 542b473

Browse files
Update ensemble.md to use standard API
1 parent 8f6bb3b commit 542b473

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/src/tutorials/ensemble.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ prob = OptimizationProblem(optf, x0, [1.0, 100.0])
1919
2020
@show sol1.objective
2121
22-
ensembleprob = Optimization.EnsembleProblem(
23-
prob, [x0, x0 .+ rand(2), x0 .+ rand(2), x0 .+ rand(2)])
22+
x0s = [x0, x0 .+ rand(2), x0 .+ rand(2), x0 .+ rand(2)]
23+
function prob_func(prob, i, repeat)
24+
remake(prob, u0 = x0s)
25+
end
2426
27+
ensembleprob = Optimization.EnsembleProblem(prob; prob_func)
2528
@time sol = Optimization.solve(ensembleprob, OptimizationOptimJL.BFGS(),
2629
EnsembleThreads(), trajectories = 4, maxiters = 5)
2730
@show findmin(i -> sol[i].objective, 1:4)[1]

0 commit comments

Comments
 (0)