Skip to content

Commit d2868cc

Browse files
Update docs/src/tutorials/reusage_interface.md
1 parent 31f1c0d commit d2868cc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

docs/src/tutorials/reusage_interface.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ p_values = [[1.0, 100.0], [2.0, 100.0], [3.0, 100.0]]
4747
# Create initial cache
4848
cache = Optimization.init(prob, Optim.BFGS())
4949
50-
for p in p_values
51-
cache = Optimization.reinit!(cache; p = p)
52-
sol = Optimization.solve!(cache)
53-
push!(results, (p = p, u = sol.u, objective = sol.objective))
50+
function sweep(cache, p_values)
51+
for p in p_values
52+
cache = Optimization.reinit!(cache; p = p)
53+
sol = Optimization.solve!(cache)
54+
push!(results, (p = p, u = sol.u, objective = sol.objective))
55+
end
5456
end
57+
58+
sweep(cache, p_values)
5559
```
5660

5761
### Example: Updating Initial Values

0 commit comments

Comments
 (0)