@@ -212,8 +212,10 @@ Direction flippedDirection(Direction direction) {
212
212
// / add these to the set of ignored columns and continue to the next row. If we
213
213
// / run out of rows, then A*y is zero and we are done.
214
214
MaybeOptimum<SmallVector<Fraction, 8 >> LexSimplex::findRationalLexMin () {
215
- if (restoreRationalConsistency ().failed ())
215
+ if (restoreRationalConsistency ().failed ()) {
216
+ markEmpty ();
216
217
return OptimumKind::Empty;
218
+ }
217
219
return getRationalSample ();
218
220
}
219
221
@@ -679,16 +681,16 @@ LogicalResult LexSimplex::restoreRationalConsistency() {
679
681
}
680
682
681
683
// Move the row unknown to column orientation while preserving lexicopositivity
682
- // of the basis transform. The sample value of the row must be negative .
684
+ // of the basis transform. The sample value of the row must be non-positive .
683
685
//
684
686
// We only consider pivots where the pivot element is positive. Suppose no such
685
687
// pivot exists, i.e., some violated row has no positive coefficient for any
686
688
// basis unknown. The row can be represented as (s + c_1*u_1 + ... + c_n*u_n)/d,
687
689
// where d is the denominator, s is the sample value and the c_i are the basis
688
- // coefficients. Since any feasible assignment of the basis satisfies u_i >= 0
689
- // for all i, and we have s < 0 as well as c_i < 0 for all i, any feasible
690
- // assignment would violate this row and therefore the constraints have no
691
- // solution.
690
+ // coefficients. If s != 0, then since any feasible assignment of the basis
691
+ // satisfies u_i >= 0 for all i, and we have s < 0 as well as c_i < 0 for all i,
692
+ // any feasible assignment would violate this row and therefore the constraints
693
+ // have no solution.
692
694
//
693
695
// We can preserve lexicopositivity by picking the pivot column with positive
694
696
// pivot element that makes the lexicographically smallest change to the sample
@@ -726,10 +728,10 @@ LogicalResult LexSimplex::restoreRationalConsistency() {
726
728
// B'.col(k) = B.col(k) - B(i,k) * B.col(j) / B(i,j) for k != j
727
729
// and similarly, s' = s - s_i * B.col(j) / B(i,j).
728
730
//
729
- // Since the row is violated, we have s_i < 0, so the change in sample value
730
- // when pivoting with column a is lexicographically smaller than that when
731
- // pivoting with column b iff B.col(a) / B(i, a) is lexicographically smaller
732
- // than B.col(b) / B(i, b).
731
+ // If s_i == 0, then the sample value remains unchanged. Otherwise, if s_i < 0,
732
+ // the change in sample value when pivoting with column a is lexicographically
733
+ // smaller than that when pivoting with column b iff B.col(a) / B(i, a) is
734
+ // lexicographically smaller than B.col(b) / B(i, b).
733
735
//
734
736
// Since B(i, j) > 0, column j remains lexicopositive.
735
737
//
@@ -749,10 +751,8 @@ LogicalResult LexSimplexBase::moveRowUnknownToColumn(unsigned row) {
749
751
!maybeColumn ? col : getLexMinPivotColumn (row, *maybeColumn, col);
750
752
}
751
753
752
- if (!maybeColumn) {
753
- markEmpty ();
754
+ if (!maybeColumn)
754
755
return failure ();
755
- }
756
756
757
757
pivot (row, *maybeColumn);
758
758
return success ();
0 commit comments