Skip to content

Commit

Permalink
Update optimizationsystem.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas authored Jul 30, 2024
1 parent be6cbb1 commit a5bc3b0
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/optimizationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ using ModelingToolkit: get_metadata
cons_h = true)
@test prob.f.sys === combinedsys
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
@test sol.minimum < -1e5
@test sol.objective < -1e5
end

@testset "inequality constraint" begin
Expand All @@ -66,14 +66,14 @@ end
grad = true, hess = true, cons_j = true, cons_h = true)
@test prob.f.sys === sys
sol = solve(prob, IPNewton())
@test sol.minimum < 1.0
@test sol.objective < 1.0
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
@test sol.minimum < 1.0
@test sol.objective < 1.0

prob = OptimizationProblem(sys, [x => 0.0, y => 0.0], [a => 1.0, b => 1.0],
grad = false, hess = false, cons_j = false, cons_h = false)
sol = solve(prob, AmplNLWriter.Optimizer(Ipopt_jll.amplexe))
@test_skip sol.minimum < 1.0
@test_skip sol.objective < 1.0
end

@testset "equality constraint" begin
Expand All @@ -88,18 +88,18 @@ end
prob = OptimizationProblem(sys, [x => 0.0, y => 0.0, z => 0.0], [a => 1.0, b => 1.0],
grad = true, hess = true, cons_j = true, cons_h = true)
sol = solve(prob, IPNewton())
@test sol.minimum < 1.0
@test sol.objective < 1.0
@test sol.u[0.808, -0.064] atol=1e-3
@test sol[x]^2 + sol[y]^2 1.0
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
@test sol.minimum < 1.0
@test sol.objective < 1.0
@test sol.u[0.808, -0.064] atol=1e-3
@test sol[x]^2 + sol[y]^2 1.0

prob = OptimizationProblem(sys, [x => 0.0, y => 0.0, z => 0.0], [a => 1.0, b => 1.0],
grad = false, hess = false, cons_j = false, cons_h = false)
sol = solve(prob, AmplNLWriter.Optimizer(Ipopt_jll.amplexe))
@test_skip sol.minimum < 1.0
@test_skip sol.objective < 1.0
@test_skip sol.u[0.808, -0.064] atol=1e-3
@test_skip sol[x]^2 + sol[y]^2 1.0
end
Expand All @@ -108,7 +108,7 @@ end
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2
x0 = zeros(2)
p = [1.0, 100.0]
f = OptimizationFunction(rosenbrock, Optimization.AutoModelingToolkit())
f = OptimizationFunction(rosenbrock, Optimization.AutoSymbolics())
prob = OptimizationProblem(f, x0, p)
sol = solve(prob, Newton())
@test sol.u [1.0, 1.0]
Expand Down Expand Up @@ -215,15 +215,15 @@ end
Ipopt.Optimizer();
print_level = 0))
#=
@test sol.minimum < -1e5
@test sol.objective < -1e5
prob = OptimizationProblem(sys2, [x => 0.0, y => 0.0], [a => 1.0, b => 100.0],
grad = true, hess = true, cons_j = true, cons_h = true)
@test prob.f.sys === sys2
sol = solve(prob, IPNewton())
@test sol.minimum < 1.0
@test sol.objective < 1.0
sol = solve(prob, Ipopt.Optimizer(); print_level = 0)
@test sol.minimum < 1.0
@test sol.objective < 1.0
=#
end

Expand Down

0 comments on commit a5bc3b0

Please sign in to comment.