Skip to content

Commit

Permalink
Add test for conic model with Ipopt (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Mar 1, 2022
1 parent 6637d78 commit d6907de
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/conic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module TestConicModels
using Test
using JuMP

import Ipopt
import Juniper
import SCS

Expand Down Expand Up @@ -41,6 +42,35 @@ function test_simple_conic_model()
return
end

function test_simple_conic_model_ipopt()
function nl_solver()
m = MOI.Bridges.full_bridge_optimizer(Ipopt.Optimizer(), Float64)
MOI.Bridges.add_bridge(
m,
MOI.Bridges.Constraint.SOCtoNonConvexQuadBridge{Float64},
)
MOI.Bridges.add_bridge(
m,
MOI.Bridges.Constraint.RSOCtoNonConvexQuadBridge{Float64},
)
return m
end
model = Model(Juniper.Optimizer)
set_optimizer_attribute(model, "nl_solver", nl_solver)
set_silent(model)
@variable(model, 0 <= x[1:2] <= 10, Int)
@objective(model, Max, 3x[1] + 5x[2])
@constraint(model, [10, x[1], x[2]] in SecondOrderCone())
optimize!(model)
@test termination_status(model) == LOCALLY_SOLVED
@test primal_status(model) == FEASIBLE_POINT
@test dual_status(model) == FEASIBLE_POINT
@test isapprox(value.(x), [6, 8]; atol = 1e-6)
@test sqrt(value(x[1])^2 + value(x[2])^2) <= 10 + 1e-6
@test isapprox(objective_value(model), 58; atol = 1e-6)
return
end

end

TestConicModels.runtests()

0 comments on commit d6907de

Please sign in to comment.