Skip to content

Commit df4cf9b

Browse files
Update optimizationsystem.jl
1 parent b94b961 commit df4cf9b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/optimizationsystem.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,22 @@ sol = solve(prob, AmplNLWriter.Optimizer(Ipopt_jll.amplexe))
6363

6464
#equality constraint, lcons == ucons
6565
cons2 = [0.0 ~ x^2 + y^2]
66+
out = zeros(1)
6667
sys2 = OptimizationSystem(loss, [x, y], [a, b], name = :sys2, constraints = cons2)
6768
prob = OptimizationProblem(sys2, [x => 0.0, y => 0.0], [a => 1.0, b => 1.0], lcons = [1.0],
6869
ucons = [1.0], grad = true, hess = true)
6970
sol = solve(prob, IPNewton())
7071
@test sol.minimum < 1.0
71-
@test prob.f.cons(sol.minimizer, [1.0, 1.0]) [1.0]
72+
prob.f.cons(out, sol.minimizer, [1.0, 1.0])
73+
@test out [1.0]
7274
sol = solve(prob, Ipopt.Optimizer())
7375
@test sol.minimum < 1.0
74-
@test prob.f.cons(sol.minimizer, [1.0, 1.0]) [1.0]
76+
prob.f.cons(out, sol.minimizer, [1.0, 1.0])
77+
@test out [1.0]
7578
sol = solve(prob, AmplNLWriter.Optimizer(Ipopt_jll.amplexe))
7679
@test sol.minimum < 1.0
77-
@test prob.f.cons(sol.minimizer, [1.0, 1.0]) [1.0]
80+
prob.f.cons(out, sol.minimizer, [1.0, 1.0])
81+
@test out [1.0]
7882

7983
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
8084
x0 = zeros(2)

0 commit comments

Comments
 (0)