@@ -1187,6 +1187,98 @@ function test_cannot_unbridge_variable_function()
1187
1187
return
1188
1188
end
1189
1189
1190
+ MOI. Utilities. @model (
1191
+ Model2452,
1192
+ (),
1193
+ (),
1194
+ (MOI. Nonnegatives, MOI. Zeros),
1195
+ (),
1196
+ (),
1197
+ (),
1198
+ (MOI. VectorOfVariables,),
1199
+ (MOI. VectorAffineFunction,)
1200
+ )
1201
+
1202
+ function MOI. supports_constraint (
1203
+ :: Model2452{T} ,
1204
+ :: Type{MOI.VariableIndex} ,
1205
+ :: Type {
1206
+ <: Union {
1207
+ MOI. GreaterThan{T},
1208
+ MOI. LessThan{T},
1209
+ MOI. EqualTo{T},
1210
+ MOI. Interval{T},
1211
+ MOI. ZeroOne,
1212
+ },
1213
+ },
1214
+ ) where {T}
1215
+ return false
1216
+ end
1217
+
1218
+ function MOI. supports_constraint (
1219
+ :: Model2452{T} ,
1220
+ :: Type{MOI.VectorOfVariables} ,
1221
+ :: Type{MOI.Reals} ,
1222
+ ) where {T}
1223
+ return false
1224
+ end
1225
+
1226
+ function test_issue_2452_multiple_variable_bridges ()
1227
+ src = MOI. Utilities. UniversalFallback (MOI. Utilities. Model {Float64} ())
1228
+ x = MOI. add_variable (src)
1229
+ MOI. add_constraint (src, x, MOI. LessThan (1.0 ))
1230
+ c = MOI. add_constraint (src, 2.0 * x, MOI. EqualTo (3.0 ))
1231
+ dest = MOI. instantiate (Model2452{Float64}; with_bridge_type = Float64)
1232
+ index_map = MOI. copy_to (dest, src)
1233
+ set = MOI. get (dest, MOI. ConstraintSet (), index_map[c])
1234
+ @test set == MOI. EqualTo (3.0 )
1235
+ MOI. set (dest, MOI. ConstraintSet (), index_map[c], set)
1236
+ @test MOI. get (dest, MOI. ConstraintSet (), index_map[c]) == set
1237
+ new_set = MOI. EqualTo (2.0 )
1238
+ MOI. set (dest, MOI. ConstraintSet (), index_map[c], new_set)
1239
+ @test MOI. get (dest, MOI. ConstraintSet (), index_map[c]) == new_set
1240
+ return
1241
+ end
1242
+
1243
+ function test_issue_2452 ()
1244
+ src = MOI. Utilities. UniversalFallback (MOI. Utilities. Model {Float64} ())
1245
+ x = MOI. add_variable (src)
1246
+ MOI. add_constraint (src, x, MOI. GreaterThan (1.0 ))
1247
+ c = MOI. add_constraint (src, 2.0 * x, MOI. EqualTo (3.0 ))
1248
+ dest = MOI. instantiate (Model2452{Float64}; with_bridge_type = Float64)
1249
+ index_map = MOI. copy_to (dest, src)
1250
+ set = MOI. get (dest, MOI. ConstraintSet (), index_map[c])
1251
+ @test set == MOI. EqualTo (3.0 )
1252
+ MOI. set (dest, MOI. ConstraintSet (), index_map[c], set)
1253
+ @test MOI. get (dest, MOI. ConstraintSet (), index_map[c]) == set
1254
+ new_set = MOI. EqualTo (2.0 )
1255
+ MOI. set (dest, MOI. ConstraintSet (), index_map[c], new_set)
1256
+ @test MOI. get (dest, MOI. ConstraintSet (), index_map[c]) == new_set
1257
+ return
1258
+ end
1259
+
1260
+ function test_issue_2452_with_constant ()
1261
+ src = MOI. Utilities. UniversalFallback (MOI. Utilities. Model {Float64} ())
1262
+ x = MOI. add_variable (src)
1263
+ MOI. add_constraint (src, x, MOI. GreaterThan (1.0 ))
1264
+ MOI. add_constraint (src, 2.0 * x + 1.0 , MOI. EqualTo (3.0 ))
1265
+ dest = MOI. instantiate (Model2452{Float64}; with_bridge_type = Float64)
1266
+ @test_throws MOI. ScalarFunctionConstantNotZero MOI. copy_to (dest, src)
1267
+ return
1268
+ end
1269
+
1270
+ function test_issue_2452_integer ()
1271
+ src = MOI. Utilities. UniversalFallback (MOI. Utilities. Model {Float64} ())
1272
+ x = MOI. add_variable (src)
1273
+ MOI. add_constraint (src, x, MOI. GreaterThan (1.0 ))
1274
+ y = MOI. add_variable (src)
1275
+ c = MOI. add_constraint (src, 1.0 * y, MOI. Integer ())
1276
+ dest = MOI. instantiate (Model2452{Float64}; with_bridge_type = Float64)
1277
+ index_map = MOI. copy_to (dest, src)
1278
+ @test MOI. get (dest, MOI. ConstraintSet (), index_map[c]) == MOI. Integer ()
1279
+ return
1280
+ end
1281
+
1190
1282
end # module
1191
1283
1192
1284
TestBridgeOptimizer. runtests ()
0 commit comments