@@ -9,6 +9,8 @@ function test_proposition_add_fail()
9
9
m = GDPModel ()
10
10
@variable (m, y[1 : 3 ], Logical)
11
11
@test_throws ErrorException @constraint (m, y[1 ] := true )
12
+ @test_throws ErrorException @constraint (m, ¬ y[1 ] := true )
13
+ @test_throws ErrorException @constraint (m, logical_not (y[1 ]) := true )
12
14
@test_throws ErrorException @constraint (Model (), logical_or (y... ) := true )
13
15
@test_throws ErrorException @constraint (m, logical_or (y... ) == 2 )
14
16
@test_throws ErrorException @constraint (m, logical_or (y... ) <= 1 )
@@ -22,33 +24,6 @@ function test_proposition_add_fail()
22
24
@test_throws AssertionError add_constraint (m, ScalarConstraint (logical_or (y... ), MOI. LessThan (42 )))
23
25
end
24
26
25
- function test_negation_add_success ()
26
- model = GDPModel ()
27
- @variable (model, y, Logical)
28
- c1 = @constraint (model, logical_not (y) := true )
29
- @constraint (model, c2, ¬ y := true )
30
- @test is_valid (model, c1)
31
- @test is_valid (model, c2)
32
- @test owner_model (c1) == model
33
- @test owner_model (c2) == model
34
- @test name (c1) == " "
35
- @test name (c2) == " c2"
36
- @test index (c1) == LogicalConstraintIndex (1 )
37
- @test index (c2) == LogicalConstraintIndex (2 )
38
- @test haskey (DP. _logical_constraints (model), index (c1))
39
- @test haskey (DP. _logical_constraints (model), index (c2))
40
- @test DP. _logical_constraints (model)[index (c1)] == DP. _constraint_data (c1)
41
- @test constraint_object (c1). func isa DP. _LogicalExpr
42
- @test constraint_object (c2). func isa DP. _LogicalExpr
43
- @test constraint_object (c1). func. head ==
44
- constraint_object (c2). func. head == :!
45
- @test constraint_object (c1). func. args ==
46
- constraint_object (c2). func. args == Any[y]
47
- @test constraint_object (c1). set ==
48
- constraint_object (c2). set == MOI. EqualTo {Bool} (true )
49
- @test c1 == copy (c1)
50
- end
51
-
52
27
function test_implication_add_success ()
53
28
model = GDPModel ()
54
29
@variable (model, y[1 : 2 ], Logical)
@@ -168,18 +143,6 @@ function test_proposition_delete()
168
143
@test ! DP. _ready_to_optimize (model)
169
144
end
170
145
171
- function test_negation_reformulation ()
172
- model = GDPModel ()
173
- @variable (model, y, Logical)
174
- @constraint (model, ¬ y := true )
175
- reformulate_model (model, DummyReformulation ())
176
- ref_con = DP. _reformulation_constraints (model)[1 ]
177
- @test is_valid (model, ref_con)
178
- ref_con_obj = constraint_object (ref_con)
179
- @test ref_con_obj. set == MOI. GreaterThan (0.0 )
180
- @test ref_con_obj. func == - DP. _indicator_to_binary (model)[y]
181
- end
182
-
183
146
function test_implication_reformulation ()
184
147
model = GDPModel ()
185
148
@variable (model, y[1 : 2 ], Logical)
@@ -222,17 +185,18 @@ end
222
185
function test_intersection_reformulation ()
223
186
model = GDPModel ()
224
187
@variable (model, y[1 : 2 ], Logical)
225
- @constraint (model, ∧ ( y[1 ], y[2 ]) := true )
188
+ @constraint (model, y[1 ] ∧ ¬ y[2 ] := true )
226
189
reformulate_model (model, DummyReformulation ())
227
190
ref_cons = DP. _reformulation_constraints (model)
228
191
@test all (is_valid .(model, ref_cons))
229
192
ref_con_objs = constraint_object .(ref_cons)
230
- @test ref_con_objs[1 ]. set ==
231
- ref_con_objs[2 ]. set == MOI. GreaterThan (1.0 )
193
+ sets = [ref_con_objs[1 ]. set, ref_con_objs[2 ]. set]
194
+ @test MOI. GreaterThan (1.0 ) in sets
195
+ @test MOI. GreaterThan (0.0 ) in sets
232
196
bvars = DP. _indicator_to_binary (model)
233
197
funcs = [ref_con_objs[1 ]. func, ref_con_objs[2 ]. func]
234
198
@test 1 bvars[y[1 ]] in funcs
235
- @test 1 bvars[y[2 ]] in funcs
199
+ @test - 1 bvars[y[2 ]] in funcs
236
200
end
237
201
238
202
function test_implication_reformulation ()
530
494
end
531
495
@testset " Add Proposition" begin
532
496
test_proposition_add_fail ()
533
- test_negation_add_success ()
534
497
test_implication_add_success ()
535
498
test_equivalence_add_success ()
536
499
test_intersection_and_flatten_add_success ()
540
503
test_proposition_add_sparse_axis ()
541
504
end
542
505
@testset " Reformulate Proposition" begin
543
- test_negation_reformulation ()
544
506
test_implication_reformulation ()
545
507
test_implication_reformulation_fail ()
546
508
test_equivalence_reformulation ()
0 commit comments