@@ -76,10 +76,16 @@ class CondEQConverter_MIP :
7676 } else if ( !GetMC ().is_fixed (res) || // not fixed, or
7777 !GetMC ().fixed_value (res) ) // fixed to 0
7878 {
79- #ifndef USE_FLAT_ALGEBRA
8079 auto bNt = GetMC ().ComputeBoundsAndType (con.GetBody ());
8180 double cmpEps = GetMC ().ComparisonEps ( bNt.get_result_type () );
82- // / res3 <==> (res || body <= rhs-eps || body >= rhs+eps)
81+ #define COND_LIN_EQ__USE_FLAT_ALGEBRA
82+ #ifndef COND_LIN_EQ__USE_FLAT_ALGEBRA
83+ // Not doing this.
84+ // Reason: the below OR propagates CTX+ into res,
85+ // which is the expression we are redefining,
86+ // but this is not necessary. See #248.
87+ // Happens on eqVarConst01.mod.
88+ // / res3 ==> (res || body <= rhs-eps || body >= rhs+eps)
8389 auto res3 = GetMC ().AssignResultVar2Args (
8490 OrConstraint{ {
8591 res,
@@ -91,16 +97,19 @@ class CondEQConverter_MIP :
9197 { { con.GetBody (), con.rhs () + cmpEps } })
9298 } });
9399 GetMC ().FixAsTrue (res3);
94- #else // USE_FLAT_ALGEBRA
95- // Old way: straight to algebra and indicators
96- auto con = eq0c.GetArguments ();
100+ #else // COND_LIN_EQ__USE_FLAT_ALGEBRA
101+ // Old way: straight to algebra and indicators.
102+ // This could duplicate the below indicators,
103+ // but simpler as of now:
104+ // the indicators redefine conditional inequalities
105+ // which, in the above variant, could have been redefined
106+ // in CTX- before, see int_ne_05_redef_ctx.mod,
107+ // thus losing the CTX+ redefinition, see #248.
97108 auto newvars = GetMC ().AddVars_returnIds (2 , 0.0 , 1.0 , var::INTEGER);
98109 newvars.push_back ( res );
99110 GetMC ().AddConstraint ( LinConGE ( // b1+b2+resvar >= 1
100111 {{1.0 , 1.0 , 1.0 }, newvars},
101112 1.0 ) );
102- auto bNt = GetMC ().ComputeBoundsAndType (con.GetBody ());
103- double cmpEps = GetMC ().ComparisonEps ( bNt.get_result_type () );
104113 {
105114 GetMC ().AddConstraint (IndicatorConstraint< AlgCon<-1 > >(
106115 newvars[0 ], 1 ,
0 commit comments