Skip to content

Commit 4407a58

Browse files
Add constraints test
1 parent 1afe6c2 commit 4407a58

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/rosenbrock.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ prob = OptimizationProblem(optprob, x0, lcons = [-Inf,-Inf], ucons = [Inf,Inf])
5959
sol = solve(prob, IPNewton())
6060
@test 10*sol.minimum < l1
6161

62+
cons_circ = (x,p) -> [x[1]^2 + x[2]^2]
63+
optprob = OptimizationFunction(rosenbrock, GalacticOptim.AutoForwardDiff();cons= cons_circ)
64+
prob = OptimizationProblem(optprob, x0, lcons = [-Inf], ucons = [0.25^2])
65+
sol = solve(prob, IPNewton())
66+
@test sqrt(cons(sol.minimizer,nothing)[1]) 0.25 rtol = 1e-6
67+
6268
optprob = OptimizationFunction(rosenbrock, GalacticOptim.AutoZygote())
6369
prob = OptimizationProblem(optprob, x0)
6470
sol = solve(prob, ADAM(), progress = false)

0 commit comments

Comments
 (0)