@@ -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
+
169
174
// / Returns the number of variables in the tableau.
170
175
unsigned getNumVariables () const ;
171
176
172
177
// / Returns the number of constraints in the tableau.
173
178
unsigned getNumConstraints () const ;
174
179
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
- virtual void addEquality (ArrayRef<int64_t > coeffs) = 0 ;
183
+ void addEquality (ArrayRef<int64_t > coeffs);
184
184
185
185
// / Add new variables to the end of the list of variables.
186
186
void appendVariable (unsigned count = 1 );
@@ -249,14 +249,6 @@ 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
-
260
252
// / Swap the row with the column in the tableau's data structures but not the
261
253
// / tableau itself. This is used by pivot.
262
254
void swapRowWithCol (unsigned row, unsigned col);
@@ -303,7 +295,6 @@ class SimplexBase {
303
295
RemoveLastVariable,
304
296
UnmarkEmpty,
305
297
UnmarkLastRedundant,
306
- UnmarkLastEquality,
307
298
RestoreBasis
308
299
};
309
300
@@ -317,14 +308,13 @@ class SimplexBase {
317
308
// / Undo the operation represented by the log entry.
318
309
void undo (UndoLogEntry entry);
319
310
320
- unsigned getNumFixedCols () const { return numFixedCols; }
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 ; }
321
314
322
315
// / Stores whether or not a big M column is present in the tableau.
323
316
bool usingBigM;
324
317
325
- // / denom + const + maybe M + equality columns
326
- unsigned numFixedCols;
327
-
328
318
// / The number of rows in the tableau.
329
319
unsigned nRow;
330
320
@@ -445,12 +435,9 @@ class LexSimplex : public SimplexBase {
445
435
// /
446
436
// / This just adds the inequality to the tableau and does not try to create a
447
437
// / consistent tableau configuration.
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 ;
438
+ void addInequality (ArrayRef<int64_t > coeffs) final {
439
+ addRow (coeffs, /* makeRestricted=*/ true );
440
+ }
454
441
455
442
// / Get a snapshot of the current state. This is used for rolling back.
456
443
unsigned getSnapshot () { return SimplexBase::getSnapshotBasis (); }
@@ -546,11 +533,6 @@ class Simplex : public SimplexBase {
546
533
// / state and marks the Simplex empty if this is not possible.
547
534
void addInequality (ArrayRef<int64_t > coeffs) final ;
548
535
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
-
554
536
// / Compute the maximum or minimum value of the given row, depending on
555
537
// / direction. The specified row is never pivoted. On return, the row may
556
538
// / have a negative sample value if the direction is down.
0 commit comments