@@ -166,21 +166,21 @@ class SimplexBase {
166
166
// / false otherwise.
167
167
bool isEmpty () const ;
168
168
169
- // / Add an inequality to the tableau. If coeffs is c_0, c_1, ... c_n, where n
170
- // / is the current number of variables, then the corresponding inequality is
171
- // / c_n + c_0*x_0 + c_1*x_1 + ... + c_{n-1}*x_{n-1} >= 0.
172
- virtual void addInequality (ArrayRef<int64_t > coeffs) = 0;
173
-
174
169
// / Returns the number of variables in the tableau.
175
170
unsigned getNumVariables () const ;
176
171
177
172
// / Returns the number of constraints in the tableau.
178
173
unsigned getNumConstraints () const ;
179
174
175
+ // / Add an inequality to the tableau. If coeffs is c_0, c_1, ... c_n, where n
176
+ // / is the current number of variables, then the corresponding inequality is
177
+ // / c_n + c_0*x_0 + c_1*x_1 + ... + c_{n-1}*x_{n-1} >= 0.
178
+ virtual void addInequality (ArrayRef<int64_t > coeffs) = 0;
179
+
180
180
// / Add an equality to the tableau. If coeffs is c_0, c_1, ... c_n, where n
181
181
// / is the current number of variables, then the corresponding equality is
182
182
// / c_n + c_0*x_0 + c_1*x_1 + ... + c_{n-1}*x_{n-1} == 0.
183
- void addEquality (ArrayRef<int64_t > coeffs);
183
+ virtual void addEquality (ArrayRef<int64_t > coeffs) = 0 ;
184
184
185
185
// / Add new variables to the end of the list of variables.
186
186
void appendVariable (unsigned count = 1 );
@@ -249,6 +249,14 @@ class SimplexBase {
249
249
// / coefficient for it.
250
250
Optional<unsigned > findAnyPivotRow (unsigned col);
251
251
252
+ // / Return any column that this row can be pivoted with, ignoring tableau
253
+ // / consistency. Equality rows are not considered.
254
+ // /
255
+ // / Returns an empty optional if no pivot is possible, which happens only when
256
+ // / the column unknown is a variable and no constraint has a non-zero
257
+ // / coefficient for it.
258
+ Optional<unsigned > findAnyPivotCol (unsigned row);
259
+
252
260
// / Swap the row with the column in the tableau's data structures but not the
253
261
// / tableau itself. This is used by pivot.
254
262
void swapRowWithCol (unsigned row, unsigned col);
@@ -295,6 +303,7 @@ class SimplexBase {
295
303
RemoveLastVariable,
296
304
UnmarkEmpty,
297
305
UnmarkLastRedundant,
306
+ UnmarkLastEquality,
298
307
RestoreBasis
299
308
};
300
309
@@ -308,13 +317,14 @@ class SimplexBase {
308
317
// / Undo the operation represented by the log entry.
309
318
void undo (UndoLogEntry entry);
310
319
311
- // / Return the number of fixed columns, as described in the constructor above,
312
- // / this is the number of columns beyond those for the variables in var.
313
- unsigned getNumFixedCols () const { return usingBigM ? 3u : 2u ; }
320
+ unsigned getNumFixedCols () const { return numFixedCols; }
314
321
315
322
// / Stores whether or not a big M column is present in the tableau.
316
323
bool usingBigM;
317
324
325
+ // / denom + const + maybe M + equality columns
326
+ unsigned numFixedCols;
327
+
318
328
// / The number of rows in the tableau.
319
329
unsigned nRow;
320
330
@@ -435,9 +445,12 @@ class LexSimplex : public SimplexBase {
435
445
// /
436
446
// / This just adds the inequality to the tableau and does not try to create a
437
447
// / consistent tableau configuration.
438
- void addInequality (ArrayRef<int64_t > coeffs) final {
439
- addRow (coeffs, /* makeRestricted=*/ true );
440
- }
448
+ void addInequality (ArrayRef<int64_t > coeffs) final ;
449
+
450
+ // / Add an equality to the tableau. If coeffs is c_0, c_1, ... c_n, where n
451
+ // / is the current number of variables, then the corresponding equality is
452
+ // / c_n + c_0*x_0 + c_1*x_1 + ... + c_{n-1}*x_{n-1} == 0.
453
+ void addEquality (ArrayRef<int64_t > coeffs) final ;
441
454
442
455
// / Get a snapshot of the current state. This is used for rolling back.
443
456
unsigned getSnapshot () { return SimplexBase::getSnapshotBasis (); }
@@ -533,6 +546,11 @@ class Simplex : public SimplexBase {
533
546
// / state and marks the Simplex empty if this is not possible.
534
547
void addInequality (ArrayRef<int64_t > coeffs) final ;
535
548
549
+ // / Add an equality to the tableau. If coeffs is c_0, c_1, ... c_n, where n
550
+ // / is the current number of variables, then the corresponding equality is
551
+ // / c_n + c_0*x_0 + c_1*x_1 + ... + c_{n-1}*x_{n-1} == 0.
552
+ void addEquality (ArrayRef<int64_t > coeffs) final ;
553
+
536
554
// / Compute the maximum or minimum value of the given row, depending on
537
555
// / direction. The specified row is never pivoted. On return, the row may
538
556
// / have a negative sample value if the direction is down.
0 commit comments