Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bridges.Constraint] add bridges in alphabetical order #2596

Merged
merged 9 commits into from
Jan 5, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update
  • Loading branch information
odow committed Jan 5, 2025
commit a1df3594af5b413705884fce64b37f07df99a24d
61 changes: 61 additions & 0 deletions test/Bridges/lazy_bridge_optimizer.jl
Original file line number Diff line number Diff line change
@@ -1704,6 +1704,67 @@ function test_MOI_runtests_No_RSOCModel()
return
end

function test_bridge_selection()
mock = MOI.Utilities.MockOptimizer(NoRSOCModel{Float64}())
bridged_mock = MOI.Bridges.LazyBridgeOptimizer(mock)

MOI.Bridges.add_bridge(
bridged_mock,
MOI.Bridges.Constraint.SplitIntervalBridge{Float64},
)
MOI.Bridges.add_bridge(
bridged_mock,
MOI.Bridges.Constraint.RSOCtoPSDBridge{Float64},
)
MOI.Bridges.add_bridge(
bridged_mock,
MOI.Bridges.Constraint.SOCtoPSDBridge{Float64},
)
MOI.Bridges.add_bridge(
bridged_mock,
MOI.Bridges.Constraint.RSOCtoSOCBridge{Float64},
)
@test !(MOI.supports_constraint(
bridged_mock,
MOI.VectorAffineFunction{Float64},
MOI.LogDetConeTriangle,
))
x = MOI.add_variables(bridged_mock, 3)
err = MOI.UnsupportedConstraint{
MOI.VectorAffineFunction{Float64},
MOI.LogDetConeTriangle,
}()
@test_throws err begin
MOI.Bridges.bridge_type(
bridged_mock,
MOI.VectorAffineFunction{Float64},
MOI.LogDetConeTriangle,
)
end
c = MOI.add_constraint(
bridged_mock,
MOI.VectorOfVariables(x),
MOI.RotatedSecondOrderCone(3),
)
@test MOI.Bridges.bridge_type(
bridged_mock,
MOI.VectorOfVariables,
MOI.RotatedSecondOrderCone,
) == MOI.Bridges.Constraint.RSOCtoSOCBridge{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blegat this test should have shown us the problem! It bridged RSOC to PSD, even though RSOC to SOC was available. It used to pick toPSD because that was the first bridge that was added.

Float64,
MOI.VectorAffineFunction{Float64},
MOI.VectorOfVariables,
}
@test MOI.Bridges.bridge(bridged_mock, c) isa
MOI.Bridges.Constraint.RSOCtoSOCBridge
@test bridged_mock.graph.constraint_dist[MOI.Bridges.node(
bridged_mock,
MOI.VectorOfVariables,
MOI.RotatedSecondOrderCone,
).index] == 1
return
end

function test_supports()
mock = MOI.Utilities.MockOptimizer(NoRSOCModel{Float64}())
full_bridged_mock = MOI.Bridges.full_bridge_optimizer(mock, Float64)
Loading