@@ -177,22 +177,21 @@ function test_reformulate_disjunct_constraint()
177177 @test reformulated_constraints[5 ][1 ]. func == JuMP. @expression (model,
178178 x .+ sum (method. M[i] * bconref[i] for i in keys (method. M))) &&
179179 reformulated_constraints[5 ][1 ]. set == MOI. Nonnegatives (2 )
180- @test reformulated_constraints[6 ][1 ]. func == JuMP. @expression (model,
181- - x .+ (1 + sum (method. M[i] * bconref[i] for i in keys (method. M)))) &&
180+ @test reformulated_constraints[6 ][1 ]. func == JuMP. @expression (model,
181+ - x .+ (1 + sum (method. M[i] * bconref[i] for i in keys (method. M)))) &&
182182 reformulated_constraints[6 ][1 ]. set == MOI. Nonnegatives (2 )
183- @test reformulated_constraints[6 ][2 ]. func == JuMP. @expression (model,
184- - x .+ (1 - sum (method. M[i] * bconref[i] for i in keys (method. M)))) &&
183+ @test reformulated_constraints[6 ][2 ]. func == JuMP. @expression (model,
184+ - x .+ (1 - sum (method. M[i] * bconref[i] for i in keys (method. M)))) &&
185185 reformulated_constraints[6 ][2 ]. set == MOI. Nonpositives (2 )
186- @test reformulated_constraints[7 ][1 ]. func == JuMP. @expression (model,
187- x[1 ] - 52 * bconref[Y[3 ]] - 53 * bconref[Y[4 ]] - bconref[Y[1 ]]
188- - 5 * bconref[Y[5 ]] - 2 * bconref[Y[2 ]]) &&
189- reformulated_constraints[7 ][1 ]. set == MOI. LessThan (1.0 )
190- @test reformulated_constraints[7 ][2 ]. func == JuMP. @expression (model,
191- x[1 ] + 52 * bconref[Y[3 ]] + 53 * bconref[Y[4 ]] + bconref[Y[1 ]]
192- + 5 * bconref[Y[5 ]] + 2 * bconref[Y[2 ]]) &&
193- reformulated_constraints[7 ][2 ]. set == MOI. GreaterThan (1.0 )
194-
195- @test_throws ErrorException reformulate_disjunct_constraint (model,
186+
187+ @test length (reformulated_constraints[7 ]) >= 2
188+ @test reformulated_constraints[7 ][1 ]. set == MOI. LessThan (1.0 )
189+ @test reformulated_constraints[7 ][2 ]. set == MOI. GreaterThan (1.0 )
190+ # Verify x[1] has coefficient 1.0 in both constraints
191+ @test JuMP. coefficient (reformulated_constraints[7 ][1 ]. func, x[1 ]) == 1.0
192+ @test JuMP. coefficient (reformulated_constraints[7 ][2 ]. func, x[1 ]) == 1.0
193+
194+ @test_throws ErrorException reformulate_disjunct_constraint (model,
196195 " odd" , bconref, method)
197196
198197end
@@ -238,30 +237,36 @@ function test_reformulate_disjunction()
238237 @constraint (model, greaterthan, x >= 1 , Disjunct (Y[1 ]))
239238 @constraint (model, interval, 0 <= x <= 55 , Disjunct (Y[2 ]))
240239 disj = disjunction (model, [Y[1 ], Y[2 ]])
241-
240+
242241 method = DP. MBM (HiGHS. Optimizer)
243242 ref_cons = reformulate_disjunction (model, constraint_object (disj), method)
244243
245244 @test length (ref_cons) == 4
246245
247246 @test ref_cons[1 ]. set == MOI. LessThan (2.0 )
248-
247+
249248 @test ref_cons[2 ]. set == MOI. GreaterThan (1.0 )
250-
249+
251250 @test ref_cons[3 ]. set == MOI. GreaterThan (0.0 )
252-
251+
253252 @test ref_cons[4 ]. set == MOI. LessThan (55.0 )
254253
255- func_1 = ref_cons[1 ]. func # x - 53 Y[2] <= 2.0
256- func_2 = ref_cons[2 ]. func # x + 53 Y[2] >= 1.0
257- func_3 = ref_cons[3 ]. func # x - Y[1] >= 0.0
258- func_4 = ref_cons[4 ]. func # x + Y[1] <= 55.0
254+ # Per-constraint M values:
255+ # - lessthan (x <= 2) in Y[2] region (0 <= x <= 55): max(x-2) at x=55 → M=53
256+ # - greaterthan (x >= 1) in Y[2] region: max(1-x) at x=0 → M=1
257+ # - interval in Y[1]: _maximize_M for Interval takes max(M_lower, M_upper)
258+ # - M_lower (x >= 0): max(-x) s.t. 1<=x<=2 → -1
259+ # - M_upper (x <= 55): max(x-55) s.t. 1<=x<=2 → -53
260+ func_1 = ref_cons[1 ]. func # x - 53*Y[2] <= 2.0
261+ func_2 = ref_cons[2 ]. func # x + 1*Y[2] >= 1.0 (per-constraint M=1)
262+ func_3 = ref_cons[3 ]. func # x + (-1)*Y[1] >= 0.0
263+ func_4 = ref_cons[4 ]. func # x - (-1)*Y[1] <= 55.0 → x + Y[1] <= 55.0
259264
260265 @test JuMP. coefficient (func_1, x) == 1.0
261266 @test JuMP. coefficient (func_1, binary_variable (Y[2 ])) == - 53.0
262267
263268 @test JuMP. coefficient (func_2, x) == 1.0
264- @test JuMP. coefficient (func_2, binary_variable (Y[2 ])) == 53.0
269+ @test JuMP. coefficient (func_2, binary_variable (Y[2 ])) == 1.0
265270
266271 @test JuMP. coefficient (func_3, x) == 1.0
267272 @test JuMP. coefficient (func_3, binary_variable (Y[1 ])) == - 1.0
0 commit comments