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

Add set for low-rank constrained SDP #2198

Merged
merged 21 commits into from
Dec 24, 2024
Prev Previous commit
Next Next commit
Fix format
blegat committed Dec 5, 2024
commit 046e0a3917a4589ecca0cf58819cbd1bd7db64aa
14 changes: 8 additions & 6 deletions src/Bridges/Variable/bridges/set_dot.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
struct DotProductsBridge{T,S,A,V} <: SetMapBridge{T,S,MOI.SetWithDotProducts{S,A,V}}
struct DotProductsBridge{T,S,A,V} <:
SetMapBridge{T,S,MOI.SetWithDotProducts{S,A,V}}
variables::Vector{MOI.VariableIndex}
constraint::MOI.ConstraintIndex{MOI.VectorOfVariables,S}
set::MOI.SetWithDotProducts{S,A,V}
@@ -55,13 +56,14 @@ end
# This returns `true` by default for `SetMapBridge`
# but is is not supported for this bridge because `inverse_map_function`
# is not implemented
function MOI.supports(::MOI.ModelLike, ::MOI.VariablePrimalStart, ::Type{<:DotProductsBridge})
function MOI.supports(
::MOI.ModelLike,
::MOI.VariablePrimalStart,
::Type{<:DotProductsBridge},
)
return false
end

function unbridged_map(
::DotProductsBridge,
::Vector{MOI.VariableIndex},
)
function unbridged_map(::DotProductsBridge, ::Vector{MOI.VariableIndex})
return nothing
end
34 changes: 17 additions & 17 deletions test/Bridges/Variable/set_dot.jl
Original file line number Diff line number Diff line change
@@ -27,30 +27,30 @@ function test_psd()
MOI.Bridges.runtests(
MOI.Bridges.Variable.DotProductsBridge,
model -> begin
x, _ = MOI.add_constrained_variables(model,
x, _ = MOI.add_constrained_variables(
model,
MOI.SetWithDotProducts(
MOI.PositiveSemidefiniteConeTriangle(2),
MOI.TriangleVectorization.([
[1 2.0
2 3],
[4 5.0
5 6],
[
1 2.0
2 3
],
[
4 5.0
5 6
],
]),
)
)
MOI.add_constraint(
model,
1.0x[1],
MOI.EqualTo(0.0),
)
MOI.add_constraint(
model,
1.0x[2],
MOI.LessThan(0.0),
),
)
MOI.add_constraint(model, 1.0x[1], MOI.EqualTo(0.0))
MOI.add_constraint(model, 1.0x[2], MOI.LessThan(0.0))
end,
model -> begin
Q, _ = MOI.add_constrained_variables(model, MOI.PositiveSemidefiniteConeTriangle(2))
Q, _ = MOI.add_constrained_variables(
model,
MOI.PositiveSemidefiniteConeTriangle(2),
)
MOI.add_constraint(
model,
1.0 * Q[1] + 4.0 * Q[2] + 3.0 * Q[3],