312
312
# Model similar to SDPA format, it gives a good example because it does not
313
313
# support a lot hence need a lot of bridges
314
314
MOI. Utilities. @model (
315
- SDPAModel ,
315
+ StandardSDPAModel ,
316
316
(),
317
317
(MOI. EqualTo,),
318
318
(MOI. Nonnegatives, MOI. PositiveSemidefiniteConeTriangle),
@@ -324,7 +324,7 @@ MOI.Utilities.@model(
324
324
)
325
325
326
326
function MOI. supports_constraint (
327
- :: SDPAModel {T} ,
327
+ :: StandardSDPAModel {T} ,
328
328
:: Type{MOI.VariableIndex} ,
329
329
:: Type {
330
330
<: Union {
@@ -341,33 +341,87 @@ function MOI.supports_constraint(
341
341
end
342
342
343
343
function MOI. supports_constraint (
344
- :: SDPAModel {T} ,
344
+ :: StandardSDPAModel {T} ,
345
345
:: Type{MOI.VectorOfVariables} ,
346
346
:: Type{MOI.Reals} ,
347
347
) where {T}
348
348
return false
349
349
end
350
350
351
351
function MOI. supports_add_constrained_variables (
352
- :: SDPAModel ,
352
+ :: StandardSDPAModel ,
353
353
:: Type{<:Union{MOI.Nonnegatives,MOI.PositiveSemidefiniteConeTriangle}} ,
354
354
)
355
355
return true
356
356
end
357
357
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
359
364
360
365
function MOI. supports (
361
- :: SDPAModel {T} ,
366
+ :: StandardSDPAModel {T} ,
362
367
:: MOI.ObjectiveFunction {
363
368
<: Union{MOI.VariableIndex,MOI.ScalarQuadraticFunction{T}} ,
364
369
},
365
370
) where {T}
366
371
return false
367
372
end
368
373
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} ()
371
425
bridged = MOI. Bridges. full_bridge_optimizer (model, Float64)
372
426
MOI. Test. runtests (
373
427
bridged,
@@ -378,7 +432,7 @@ function test_MOI_runtests_SDPAModel()
378
432
end
379
433
380
434
function test_show_SPDA ()
381
- model = SDPAModel {Float64} ()
435
+ model = StandardSDPAModel {Float64} ()
382
436
model_str = sprint (MOI. Utilities. print_with_acronym, string (typeof (model)))
383
437
bridged = MOI. Bridges. full_bridge_optimizer (model, Float64)
384
438
# no bridges
@@ -401,7 +455,7 @@ function test_show_SPDA()
401
455
end
402
456
403
457
function _test_SDPA_format (T)
404
- model = SDPAModel {T} ()
458
+ model = StandardSDPAModel {T} ()
405
459
bridged = MOI. Bridges. LazyBridgeOptimizer (model)
406
460
@test ! MOI. supports_constraint (
407
461
model,
@@ -712,7 +766,7 @@ function test_SDPA_debug()
712
766
end
713
767
714
768
function _test_SDPA_debug (T)
715
- model = SDPAModel {T} ()
769
+ model = StandardSDPAModel {T} ()
716
770
bridged = MOI. Bridges. LazyBridgeOptimizer (model)
717
771
function debug_string (f, args... )
718
772
s = IOBuffer ()
@@ -1071,8 +1125,8 @@ Bridge graph with 1 variable nodes, 5 constraint nodes and 2 objective nodes.
1071
1125
end
1072
1126
end
1073
1127
1074
- function _test_continuous_SDPAModel (T)
1075
- model = SDPAModel {T} ()
1128
+ function _test_continuous_StandardSDPAModel (T)
1129
+ model = StandardSDPAModel {T} ()
1076
1130
bridged = MOI. Bridges. full_bridge_optimizer (model, T)
1077
1131
# For `ScalarAffineFunction`-in-`GreaterThan`,
1078
1132
# `Constraint.ScalarSlackBridge` -> `Variable.VectorizeBridge`
@@ -1098,13 +1152,13 @@ function _test_continuous_SDPAModel(T)
1098
1152
return
1099
1153
end
1100
1154
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})
1104
1158
return
1105
1159
end
1106
1160
1107
- function test_SDPAModel_with_bridges_and_caching ()
1161
+ function test_StandardSDPAModel_with_bridges_and_caching ()
1108
1162
# This tests that the computation of the reverse dict in the
1109
1163
# caching optimizer works with negative indices
1110
1164
cached = MOI. Utilities. CachingOptimizer (
@@ -1114,7 +1168,7 @@ function test_SDPAModel_with_bridges_and_caching()
1114
1168
vi_cache = MOI. add_variable (cached)
1115
1169
f (vi) = 1.0 * vi
1116
1170
ci_cache = MOI. add_constraint (cached, f (vi_cache), MOI. EqualTo (1.0 ))
1117
- model = SDPAModel {Float64} ()
1171
+ model = StandardSDPAModel {Float64} ()
1118
1172
bridged = MOI. Bridges. full_bridge_optimizer (model, Float64)
1119
1173
MOI. Utilities. reset_optimizer (cached, bridged)
1120
1174
MOI. Utilities. attach_optimizer (cached)
@@ -1136,8 +1190,8 @@ function test_SDPAModel_with_bridges_and_caching()
1136
1190
return
1137
1191
end
1138
1192
1139
- function test_conic_SDPAModel ()
1140
- model = SDPAModel {Float64} ()
1193
+ function test_conic_StandardSDPAModel ()
1194
+ model = StandardSDPAModel {Float64} ()
1141
1195
bridged = MOI. Bridges. full_bridge_optimizer (model, Float64)
1142
1196
MOI. Test. test_conic_PositiveSemidefiniteConeSquare_VectorOfVariables (
1143
1197
bridged,
@@ -1972,6 +2026,27 @@ function test_toadd()
1972
2026
@test ! MOI. Bridges. has_bridge (b, BridgeListOfNonstandardBridges{Float64})
1973
2027
end
1974
2028
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
+
1975
2050
end # module
1976
2051
1977
2052
TestBridgesLazyBridgeOptimizer. runtests ()
0 commit comments