312312# Model similar to SDPA format, it gives a good example because it does not
313313# support a lot hence need a lot of bridges
314314MOI. Utilities. @model (
315- SDPAModel ,
315+ StandardSDPAModel ,
316316 (),
317317 (MOI. EqualTo,),
318318 (MOI. Nonnegatives, MOI. PositiveSemidefiniteConeTriangle),
@@ -324,7 +324,7 @@ MOI.Utilities.@model(
324324)
325325
326326function MOI. supports_constraint (
327- :: SDPAModel {T} ,
327+ :: StandardSDPAModel {T} ,
328328 :: Type{MOI.VariableIndex} ,
329329 :: Type {
330330 <: Union {
@@ -341,33 +341,87 @@ function MOI.supports_constraint(
341341end
342342
343343function MOI. supports_constraint (
344- :: SDPAModel {T} ,
344+ :: StandardSDPAModel {T} ,
345345 :: Type{MOI.VectorOfVariables} ,
346346 :: Type{MOI.Reals} ,
347347) where {T}
348348 return false
349349end
350350
351351function MOI. supports_add_constrained_variables (
352- :: SDPAModel ,
352+ :: StandardSDPAModel ,
353353 :: Type{<:Union{MOI.Nonnegatives,MOI.PositiveSemidefiniteConeTriangle}} ,
354354)
355355 return true
356356end
357357
358- MOI. supports_add_constrained_variables (:: SDPAModel , :: Type{MOI.Reals} ) = false
358+ function MOI. supports_add_constrained_variables (
359+ :: StandardSDPAModel ,
360+ :: Type{MOI.Reals} ,
361+ )
362+ return false
363+ end
359364
360365function MOI. supports (
361- :: SDPAModel {T} ,
366+ :: StandardSDPAModel {T} ,
362367 :: MOI.ObjectiveFunction {
363368 <: Union{MOI.VariableIndex,MOI.ScalarQuadraticFunction{T}} ,
364369 },
365370) where {T}
366371 return false
367372end
368373
369- function test_MOI_runtests_SDPAModel ()
370- model = SDPAModel {Float64} ()
374+ MOI. Utilities. @model (
375+ GeometricSDPAModel,
376+ (),
377+ (),
378+ (MOI. Zeros, MOI. Nonnegatives, MOI. PositiveSemidefiniteConeTriangle),
379+ (),
380+ (),
381+ (),
382+ (),
383+ (MOI. VectorAffineFunction,)
384+ )
385+
386+ function MOI. supports_constraint (
387+ :: GeometricSDPAModel{T} ,
388+ :: Type{MOI.VariableIndex} ,
389+ :: Type {
390+ <: Union {
391+ MOI. GreaterThan{T},
392+ MOI. LessThan{T},
393+ MOI. EqualTo{T},
394+ MOI. Interval{T},
395+ MOI. ZeroOne,
396+ MOI. Integer,
397+ },
398+ },
399+ ) where {T}
400+ return false
401+ end
402+
403+ function MOI. supports (
404+ :: StandardSDPAModel{T} ,
405+ :: MOI.ObjectiveFunction {
406+ <: Union{MOI.VariableIndex,MOI.ScalarQuadraticFunction{T}} ,
407+ },
408+ ) where {T}
409+ return false
410+ end
411+
412+ function test_MOI_runtests_StandardSDPAModel ()
413+ model = StandardSDPAModel {Float64} ()
414+ bridged = MOI. Bridges. full_bridge_optimizer (model, Float64)
415+ MOI. Test. runtests (
416+ bridged,
417+ MOI. Test. Config (exclude = Any[MOI. optimize!]),
418+ include = [" ConstraintName" , " VariableName" ],
419+ )
420+ return
421+ end
422+
423+ function test_MOI_runtests_GeometricSDPAModel ()
424+ model = GeometricSDPAModel {Float64} ()
371425 bridged = MOI. Bridges. full_bridge_optimizer (model, Float64)
372426 MOI. Test. runtests (
373427 bridged,
@@ -378,7 +432,7 @@ function test_MOI_runtests_SDPAModel()
378432end
379433
380434function test_show_SPDA ()
381- model = SDPAModel {Float64} ()
435+ model = StandardSDPAModel {Float64} ()
382436 model_str = sprint (MOI. Utilities. print_with_acronym, string (typeof (model)))
383437 bridged = MOI. Bridges. full_bridge_optimizer (model, Float64)
384438 # no bridges
@@ -401,7 +455,7 @@ function test_show_SPDA()
401455end
402456
403457function _test_SDPA_format (T)
404- model = SDPAModel {T} ()
458+ model = StandardSDPAModel {T} ()
405459 bridged = MOI. Bridges. LazyBridgeOptimizer (model)
406460 @test ! MOI. supports_constraint (
407461 model,
@@ -712,7 +766,7 @@ function test_SDPA_debug()
712766end
713767
714768function _test_SDPA_debug (T)
715- model = SDPAModel {T} ()
769+ model = StandardSDPAModel {T} ()
716770 bridged = MOI. Bridges. LazyBridgeOptimizer (model)
717771 function debug_string (f, args... )
718772 s = IOBuffer ()
@@ -1071,8 +1125,8 @@ Bridge graph with 1 variable nodes, 5 constraint nodes and 2 objective nodes.
10711125 end
10721126end
10731127
1074- function _test_continuous_SDPAModel (T)
1075- model = SDPAModel {T} ()
1128+ function _test_continuous_StandardSDPAModel (T)
1129+ model = StandardSDPAModel {T} ()
10761130 bridged = MOI. Bridges. full_bridge_optimizer (model, T)
10771131 # For `ScalarAffineFunction`-in-`GreaterThan`,
10781132 # `Constraint.ScalarSlackBridge` -> `Variable.VectorizeBridge`
@@ -1098,13 +1152,13 @@ function _test_continuous_SDPAModel(T)
10981152 return
10991153end
11001154
1101- function test_continuous_SDPAModel ()
1102- _test_continuous_SDPAModel (Float64)
1103- _test_continuous_SDPAModel (Rational{Int})
1155+ function test_continuous_StandardSDPAModel ()
1156+ _test_continuous_StandardSDPAModel (Float64)
1157+ _test_continuous_StandardSDPAModel (Rational{Int})
11041158 return
11051159end
11061160
1107- function test_SDPAModel_with_bridges_and_caching ()
1161+ function test_StandardSDPAModel_with_bridges_and_caching ()
11081162 # This tests that the computation of the reverse dict in the
11091163 # caching optimizer works with negative indices
11101164 cached = MOI. Utilities. CachingOptimizer (
@@ -1114,7 +1168,7 @@ function test_SDPAModel_with_bridges_and_caching()
11141168 vi_cache = MOI. add_variable (cached)
11151169 f (vi) = 1.0 * vi
11161170 ci_cache = MOI. add_constraint (cached, f (vi_cache), MOI. EqualTo (1.0 ))
1117- model = SDPAModel {Float64} ()
1171+ model = StandardSDPAModel {Float64} ()
11181172 bridged = MOI. Bridges. full_bridge_optimizer (model, Float64)
11191173 MOI. Utilities. reset_optimizer (cached, bridged)
11201174 MOI. Utilities. attach_optimizer (cached)
@@ -1136,8 +1190,8 @@ function test_SDPAModel_with_bridges_and_caching()
11361190 return
11371191end
11381192
1139- function test_conic_SDPAModel ()
1140- model = SDPAModel {Float64} ()
1193+ function test_conic_StandardSDPAModel ()
1194+ model = StandardSDPAModel {Float64} ()
11411195 bridged = MOI. Bridges. full_bridge_optimizer (model, Float64)
11421196 MOI. Test. test_conic_PositiveSemidefiniteConeSquare_VectorOfVariables (
11431197 bridged,
@@ -1972,6 +2026,27 @@ function test_toadd()
19722026 @test ! MOI. Bridges. has_bridge (b, BridgeListOfNonstandardBridges{Float64})
19732027end
19742028
2029+ function test_hermitian (T = Float64)
2030+ model = StandardSDPAModel {T} ()
2031+ bridged = MOI. Bridges. full_bridge_optimizer (model, T)
2032+ S = MOI. HermitianPositiveSemidefiniteConeTriangle
2033+ MOI. Bridges. bridge_type (bridged, S) ==
2034+ MOI. Bridges. Variable. HermitianToSymmetricPSDBridge{T}
2035+ # FIXME This would actually better to functionize, slack and do the variable bridge here
2036+ # but since it is 3 bridges, it does not choose it
2037+ @test MOI. Bridges. bridge_type (bridged, MOI. VectorOfVariables, S) < :
2038+ MOI. Bridges. Constraint. HermitianToSymmetricPSDBridge{T}
2039+ @test MOI. Bridges. bridge_type (bridged, MOI. VectorAffineFunction{T}, S) < :
2040+ MOI. Bridges. Constraint. VectorSlackBridge{T}
2041+ model = GeometricSDPAModel {T} ()
2042+ bridged = MOI. Bridges. full_bridge_optimizer (model, T)
2043+ @test ! MOI. Bridges. is_variable_bridged (bridged, S)
2044+ for F in [MOI. VectorOfVariables, MOI. VectorAffineFunction{T}]
2045+ @test MOI. Bridges. bridge_type (bridged, F, S) < :
2046+ MOI. Bridges. Constraint. HermitianToSymmetricPSDBridge{T}
2047+ end
2048+ end
2049+
19752050end # module
19762051
19772052TestBridgesLazyBridgeOptimizer. runtests ()
0 commit comments