@@ -1157,6 +1157,50 @@ function test_parse_int_coefficient_scalarquadraticfunction()
11571157 return
11581158end
11591159
1160+ function test_parse_constraintname_variable ()
1161+ io = IOBuffer ()
1162+ print (
1163+ io,
1164+ """ {
1165+ "version": {"major": 1, "minor": 2},
1166+ "variables": [{"name": "x", "primal_start": 0.0}],
1167+ "objective": {"sense": "min", "function": {"type": "Variable", "name": "x"}},
1168+ "constraints": [{
1169+ "name": "x >= 1",
1170+ "function": {
1171+ "type": "ScalarAffineFunction",
1172+ "terms": [{"coefficient": 1, "variable": "x"}],
1173+ "constant": 0
1174+ },
1175+ "set": {"type": "GreaterThan", "lower": 1},
1176+ "primal_start": 1,
1177+ "dual_start": 0
1178+ }, {
1179+ "name": "x ∈ [0, 1]",
1180+ "function": {"type": "Variable", "name": "x"},
1181+ "set": {"type": "Interval", "lower": 0, "upper": 1}
1182+ }]
1183+ }""" ,
1184+ )
1185+ seekstart (io)
1186+ model = MOF. Model ()
1187+ read! (io, model)
1188+ x = MOI. get (model, MOI. VariableIndex, " x" )
1189+ @test MOI. get (model, MOI. NumberOfVariables ()) == 1
1190+ @test MOI. get (model, MOI. VariablePrimalStart (), x) == 0.0
1191+ F, S = MOI. VariableIndex, MOI. Interval{Float64}
1192+ @test MOI. get (model, MOI. NumberOfConstraints {F,S} ()) == 1
1193+ ci = first (MOI. get (model, MOI. ListOfConstraintIndices {F,S} ()))
1194+ @test MOI. get (model, MOI. ConstraintFunction (), ci) == x
1195+ @test MOI. get (model, MOI. ConstraintSet (), ci) == MOI. Interval (0.0 , 1.0 )
1196+ F, S = MOI. ScalarAffineFunction{Float64}, MOI. GreaterThan{Float64}
1197+ @test isa (
1198+ MOI. get (model, MOI. ConstraintIndex, " x >= 1" ),
1199+ MOI. ConstraintIndex{F,S},
1200+ )
1201+ return
1202+ end
1203+
11601204function runtests ()
11611205 for name in names (@__MODULE__ , all = true )
11621206 if startswith (" $(name) " , " test_" )
0 commit comments