@@ -252,8 +252,10 @@ public IntVar mult(final IntVar left, final int right) {
252
252
final Domain domain = left .getDomain ();
253
253
final long lDomainMinResult = domain .min () * right ;
254
254
final long lDomainMaxResult = domain .max () * right ;
255
- final long lb = Math .min (lDomainMinResult , lDomainMaxResult );
256
- final long ub = Math .max (lDomainMinResult , lDomainMaxResult );
255
+
256
+ // Conservative. Should be fixed with: https://github.com/vmware/declarative-cluster-management/issues/112
257
+ final long lb = Math .max (Math .min (lDomainMinResult , lDomainMaxResult ), Integer .MIN_VALUE );
258
+ final long ub = Math .min (Math .max (lDomainMinResult , lDomainMaxResult ), Integer .MAX_VALUE );
257
259
final IntVar ret = model .newIntVar (lb , ub , "" );
258
260
model .addEquality (ret , LinearExpr .term (left , right ));
259
261
return ret ;
@@ -266,8 +268,10 @@ public IntVar mult(final IntVar left, final IntVar right) {
266
268
final long lDomainMax = lDomain .max ();
267
269
final long rDomainMin = rDomain .min ();
268
270
final long rDomainMax = rDomain .max ();
269
- final long lb = Math .min (lDomainMin * rDomainMin , lDomainMax * rDomainMax );
270
- final long ub = Math .max (lDomainMin * rDomainMin , lDomainMax * rDomainMax );
271
+
272
+ // Conservative. Should be fixed with: https://github.com/vmware/declarative-cluster-management/issues/112
273
+ final long lb = Math .max (Math .min (lDomainMin * rDomainMin , lDomainMax * rDomainMax ), Integer .MIN_VALUE );
274
+ final long ub = Math .min (Math .max (lDomainMin * rDomainMin , lDomainMax * rDomainMax ), Integer .MAX_VALUE );
271
275
final IntVar ret = model .newIntVar (lb , ub , "" );
272
276
model .addProductEquality (ret , new IntVar []{left , right });
273
277
return ret ;
0 commit comments