Skip to content

Commit 1551d6e

Browse files
added fix for COBYLA example in docs
Signed-off-by: AdityaPandeyCN <[email protected]>
1 parent 4799e03 commit 1551d6e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/src/optimization_packages/scipy.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ using Optimization, OptimizationSciPy
8282
# Objective
8383
obj(x, p) = (x[1] + x[2] - 1)^2
8484
85-
# Single non-linear equality: x₁² + x₂² = 1
85+
# Single non-linear constraint: x₁² + x₂² ≈ 1 (with small tolerance)
8686
cons(res, x, p) = (res .= [x[1]^2 + x[2]^2 - 1.0])
8787
8888
x0 = [0.5, 0.5]
8989
prob = OptimizationProblem(
9090
OptimizationFunction(obj; cons = cons),
91-
x0, nothing, lcons = [0.0], ucons = [0.0])
91+
x0, nothing, lcons = [-1e-6], ucons = [1e-6]) # Small tolerance instead of exact equality
9292
9393
sol = solve(prob, ScipyCOBYLA())
9494
@show sol.u, sol.objective
@@ -130,3 +130,4 @@ If SciPy raises an error it is re-thrown as a Julia `ErrorException` carrying th
130130
## Contributing
131131

132132
Bug reports and feature requests are welcome in the [Optimization.jl](https://github.com/SciML/Optimization.jl) issue tracker. Pull requests that improve either the Julia wrapper or the documentation are highly appreciated.
133+

0 commit comments

Comments
 (0)