File tree 7 files changed +108
-9
lines changed 7 files changed +108
-9
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,14 @@ MOI.Utilities.@model(
46
46
(MOI. VectorAffineFunction,)
47
47
)
48
48
49
+ function MOI. supports_constraint (
50
+ :: Model ,
51
+ :: Type{MOI.VariableIndex} ,
52
+ :: Type{<:Union{MOI.Parameter,MOI.Semicontinuous,MOI.Semiinteger}} ,
53
+ )
54
+ return false
55
+ end
56
+
49
57
function MOI. supports_constraint (
50
58
:: Model{T} ,
51
59
:: Type{MOI.VectorAffineFunction{T}} ,
Original file line number Diff line number Diff line change @@ -74,6 +74,14 @@ function MOI.supports_constraint(
74
74
return false
75
75
end
76
76
77
+ function MOI. supports_constraint (
78
+ :: Model ,
79
+ :: Type{MOI.VariableIndex} ,
80
+ :: Type{<:Union{MOI.Parameter,MOI.Semicontinuous,MOI.Semiinteger}} ,
81
+ )
82
+ return false
83
+ end
84
+
77
85
function MOI. supports_constraint (
78
86
:: Model{T} ,
79
87
:: Type{MOI.VectorOfVariables} ,
Original file line number Diff line number Diff line change @@ -699,6 +699,23 @@ function test_supports_quadratic_objective()
699
699
return
700
700
end
701
701
702
+ function test_unsupported_variable_types ()
703
+ model = CBF. Model ()
704
+ @test_throws (
705
+ MOI. UnsupportedConstraint,
706
+ MOI. add_constrained_variable (model, MOI. Parameter (2.0 )),
707
+ )
708
+ @test_throws (
709
+ MOI. UnsupportedConstraint,
710
+ MOI. add_constrained_variable (model, MOI. Semicontinuous (2.0 , 3.0 )),
711
+ )
712
+ @test_throws (
713
+ MOI. UnsupportedConstraint,
714
+ MOI. add_constrained_variable (model, MOI. Semiinteger (2.0 , 3.0 )),
715
+ )
716
+ return
717
+ end
718
+
702
719
end # module
703
720
704
721
TestCBF. runtests ()
Original file line number Diff line number Diff line change @@ -1113,6 +1113,23 @@ function test_unable_to_parse_bound()
1113
1113
return
1114
1114
end
1115
1115
1116
+ function test_unsupported_variable_types ()
1117
+ model = LP. Model ()
1118
+ @test_throws (
1119
+ MOI. UnsupportedConstraint,
1120
+ MOI. add_constrained_variable (model, MOI. Parameter (2.0 )),
1121
+ )
1122
+ @test_throws (
1123
+ MOI. UnsupportedConstraint,
1124
+ MOI. add_constrained_variable (model, MOI. Semicontinuous (2.0 , 3.0 )),
1125
+ )
1126
+ @test_throws (
1127
+ MOI. UnsupportedConstraint,
1128
+ MOI. add_constrained_variable (model, MOI. Semiinteger (2.0 , 3.0 )),
1129
+ )
1130
+ return
1131
+ end
1132
+
1116
1133
end # module
1117
1134
1118
1135
TestLP. runtests ()
Original file line number Diff line number Diff line change @@ -1533,6 +1533,23 @@ function test_malformed_indicator()
1533
1533
return
1534
1534
end
1535
1535
1536
+ function test_unsupported_variable_types ()
1537
+ model = MPS. Model ()
1538
+ @test_throws (
1539
+ MOI. UnsupportedConstraint,
1540
+ MOI. add_constrained_variable (model, MOI. Parameter (2.0 )),
1541
+ )
1542
+ @test_throws (
1543
+ MOI. UnsupportedConstraint,
1544
+ MOI. add_constrained_variable (model, MOI. Semicontinuous (2.0 , 3.0 )),
1545
+ )
1546
+ @test_throws (
1547
+ MOI. UnsupportedConstraint,
1548
+ MOI. add_constrained_variable (model, MOI. Semiinteger (2.0 , 3.0 )),
1549
+ )
1550
+ return
1551
+ end
1552
+
1536
1553
end # TestMPS
1537
1554
1538
1555
TestMPS. runtests ()
Original file line number Diff line number Diff line change 6
6
7
7
module TestNLModel
8
8
9
+ using Test
10
+
9
11
import MathOptInterface as MOI
10
- const NL = MOI . FileFormats. NL
12
+ import MathOptInterface . FileFormats: NL
11
13
12
- using Test
14
+ function runtests ()
15
+ for name in names (@__MODULE__ ; all = true )
16
+ if startswith (" $(name) " , " test_" )
17
+ @testset " $(name) " begin
18
+ getfield (@__MODULE__ , name)()
19
+ end
20
+ end
21
+ end
22
+ return
23
+ end
13
24
14
25
function _test_nlexpr (
15
26
expr:: NL._NLExpr ,
@@ -1352,14 +1363,18 @@ function test_copy_name_issue_2445()
1352
1363
return
1353
1364
end
1354
1365
1355
- function runtests ()
1356
- for name in names (@__MODULE__ ; all = true )
1357
- if startswith (" $(name) " , " test_" )
1358
- @testset " $(name) " begin
1359
- getfield (@__MODULE__ , name)()
1360
- end
1361
- end
1366
+ function test_unsupported_variable_types ()
1367
+ for set in (
1368
+ MOI. Parameter (2.0 ),
1369
+ MOI. Semicontinuous (2.0 , 3.0 ),
1370
+ MOI. Semiinteger (2.0 , 3.0 ),
1371
+ )
1372
+ src = MOI. Utilities. Model {Float64} ()
1373
+ MOI. add_constrained_variable (src, set)
1374
+ dest = NL. Model ()
1375
+ @test_throws MOI. UnsupportedConstraint MOI. copy_to (dest, src)
1362
1376
end
1377
+ return
1363
1378
end
1364
1379
1365
1380
end
Original file line number Diff line number Diff line change @@ -363,6 +363,23 @@ function test_integer_before_variables()
363
363
return
364
364
end
365
365
366
+ function test_unsupported_variable_types ()
367
+ model = SDPA. Model ()
368
+ @test_throws (
369
+ MOI. UnsupportedConstraint,
370
+ MOI. add_constrained_variable (model, MOI. Parameter (2.0 )),
371
+ )
372
+ @test_throws (
373
+ MOI. UnsupportedConstraint,
374
+ MOI. add_constrained_variable (model, MOI. Semicontinuous (2.0 , 3.0 )),
375
+ )
376
+ @test_throws (
377
+ MOI. UnsupportedConstraint,
378
+ MOI. add_constrained_variable (model, MOI. Semiinteger (2.0 , 3.0 )),
379
+ )
380
+ return
381
+ end
382
+
366
383
end # module
367
384
368
385
TestSDPA. runtests ()
You can’t perform that action at this time.
0 commit comments