@@ -357,8 +357,8 @@ bool SymbolicLexSimplex::isSymbolicSampleIntegral(unsigned row) const {
357
357
isRangeDivisibleBy (tableau.getRow (row).slice (3 , nSymbol), denom);
358
358
}
359
359
360
- // / This proceeds similarly to LexSimplex ::addCut(). We are given a row that has
361
- // / a symbolic sample value with fractional coefficients.
360
+ // / This proceeds similarly to LexSimplexBase ::addCut(). We are given a row that
361
+ // / has a symbolic sample value with fractional coefficients.
362
362
// /
363
363
// / Let the row be
364
364
// / (c + coeffM*M + sum_i a_i*s_i + sum_j b_j*y_j)/d,
@@ -374,10 +374,11 @@ bool SymbolicLexSimplex::isSymbolicSampleIntegral(unsigned row) const {
374
374
// / sum_i (b_i%d)y_i = ((-c%d) + sum_i (-a_i%d)s_i)%d + k*d for some integer k
375
375
// /
376
376
// / where we take a modulo of the whole symbolic expression on the right to
377
- // / bring it into the range [0, d - 1]. Therefore, as in LexSimplex:: addCut,
377
+ // / bring it into the range [0, d - 1]. Therefore, as in addCut() ,
378
378
// / k is the quotient on dividing the LHS by d, and since LHS >= 0, we have
379
- // / k >= 0 as well. We realize the modulo of the symbolic expression by adding a
380
- // / division variable
379
+ // / k >= 0 as well. If all the a_i are divisible by d, then we can add the
380
+ // / constraint directly. Otherwise, we realize the modulo of the symbolic
381
+ // / expression by adding a division variable
381
382
// /
382
383
// / q = ((-c%d) + sum_i (-a_i%d)s_i)/d
383
384
// /
@@ -392,16 +393,22 @@ bool SymbolicLexSimplex::isSymbolicSampleIntegral(unsigned row) const {
392
393
LogicalResult SymbolicLexSimplex::addSymbolicCut (unsigned row) {
393
394
int64_t d = tableau (row, 0 );
394
395
395
- // Add the division variable `q` described above to the symbol domain.
396
- // q = ((-c%d) + sum_i (-a_i%d)s_i)/d.
396
+ // Construct the division variable `q = ((-c%d) + sum_i (-a_i%d)s_i)/d`.
397
397
SmallVector<int64_t , 8 > divCoeffs;
398
398
divCoeffs.reserve (nSymbol + 1 );
399
399
int64_t divDenom = d;
400
400
for (unsigned col = 3 ; col < 3 + nSymbol; ++col)
401
401
divCoeffs.push_back (mod (-tableau (row, col), divDenom)); // (-a_i%d)s_i
402
402
divCoeffs.push_back (mod (-tableau (row, 1 ), divDenom)); // -c%d.
403
-
404
403
normalizeDiv (divCoeffs, divDenom);
404
+
405
+ if (divDenom == 1 ) {
406
+ // The symbolic sample numerator is divisible by the denominator,
407
+ // so the division isn't needed. We can add the constraint directly,
408
+ // i.e., ignore the symbols and add a regular cut as in addCut().
409
+ return addCut (row);
410
+ }
411
+
405
412
domainSimplex.addDivisionVariable (divCoeffs, divDenom);
406
413
domainPoly.addLocalFloorDiv (divCoeffs, divDenom);
407
414
0 commit comments