speedup sat-lp connection
This commit is contained in:
@@ -50,9 +50,6 @@
|
||||
// s1 is an m1-vector (m1 being the height of A1),
|
||||
// s2 is an m2-vector (m2 being the height of A2).
|
||||
//
|
||||
// See Design Document at
|
||||
// or search for "Google Linear Programming" in Docs
|
||||
//
|
||||
// The following are very good references for terminology, data structures,
|
||||
// and algorithms. They all contain a wealth of references.
|
||||
//
|
||||
|
||||
@@ -641,7 +641,7 @@ void LinearProgram::AddSlackVariablesWhereNecessary(
|
||||
// Clean up the matrix. We're going to add entries, but we'll only be adding
|
||||
// them to new columns, and only one entry per column, which does not
|
||||
// invalidate the "cleanness" of the matrix.
|
||||
matrix_.CleanUp();
|
||||
CleanUp();
|
||||
|
||||
// Detect which constraints produce an integer slack variable. A constraint
|
||||
// has an integer slack variable, if it contains only integer variables with
|
||||
@@ -682,6 +682,8 @@ void LinearProgram::AddSlackVariablesWhereNecessary(
|
||||
SetCoefficient(row, slack_col, 1.0);
|
||||
SetConstraintBounds(row, 0.0, 0.0);
|
||||
}
|
||||
|
||||
columns_are_known_to_be_clean_ = true;
|
||||
transpose_matrix_is_consistent_ = false;
|
||||
if (first_slack_variable_ == kInvalidCol) {
|
||||
first_slack_variable_ = original_num_variables;
|
||||
|
||||
@@ -521,6 +521,16 @@ class LinearProgram {
|
||||
// integer bounds.
|
||||
bool BoundsOfIntegerConstraintsAreInteger(Fractional tolerance) const;
|
||||
|
||||
// Advanced usage. Bypass the costly call to CleanUp() when we known that the
|
||||
// change we made kept the matrix columns "clean" (see the comment of
|
||||
// CleanUp()). This is unsafe but can save a big chunk of the running time
|
||||
// when one does a small amount of incremental changes to the problem (like
|
||||
// adding a new row with no duplicates or zero entries).
|
||||
void NotifyThatColumnsAreClean() {
|
||||
DCHECK(matrix_.IsCleanedUp());
|
||||
columns_are_known_to_be_clean_ = true;
|
||||
}
|
||||
|
||||
private:
|
||||
// A helper function that updates the vectors integer_variables_list_,
|
||||
// binary_variables_list_, and non_binary_variables_list_.
|
||||
|
||||
@@ -239,6 +239,7 @@ bool LinearProgrammingConstraint::Propagate() {
|
||||
if (num_new_cuts > 0) {
|
||||
num_cuts_ += num_new_cuts;
|
||||
VLOG(1) << "#cuts " << num_cuts_;
|
||||
lp_data_.NotifyThatColumnsAreClean();
|
||||
lp_data_.AddSlackVariablesWhereNecessary(false);
|
||||
const auto status = simplex_.Solve(lp_data_, time_limit_);
|
||||
CHECK(status.ok()) << "LinearProgrammingConstraint encountered an error: "
|
||||
|
||||
Reference in New Issue
Block a user