improve scaling

This commit is contained in:
Laurent Perron
2017-09-06 10:17:38 +02:00
parent c36066c39c
commit 673cdb9f6c
3 changed files with 12 additions and 7 deletions

View File

@@ -237,7 +237,6 @@ void ReducedCosts::PerturbCosts() {
SCOPED_TIME_STAT(&stats_);
VLOG(1) << "Perturbing the costs ... ";
// Note(user): The max_cost_magnitude should be 1.0 when cost scaling is on.
Fractional max_cost_magnitude = 0.0;
const ColIndex structural_size =
matrix_.num_cols() - RowToColIndex(matrix_.num_rows());

View File

@@ -2909,12 +2909,17 @@ void RevisedSimplex::DisplayVariableBounds() {
}
}
ITIVector<RowIndex, SparseRow> RevisedSimplex::ComputeDictionary() {
ITIVector<RowIndex, SparseRow> RevisedSimplex::ComputeDictionary(
const SparseMatrixScaler* scaler) {
ITIVector<RowIndex, SparseRow> dictionary(num_rows_.value());
for (ColIndex col(0); col < num_cols_; ++col) {
ComputeDirection(col);
for (const RowIndex row : direction_non_zero_) {
dictionary[row].SetCoefficient(col, direction_[row]);
const Fractional scale_coefficient =
scaler == nullptr
? 1.0
: scaler->col_scale(col) / scaler->col_scale(GetBasis(row));
dictionary[row].SetCoefficient(col, direction_[row] * scale_coefficient);
}
}
return dictionary;
@@ -2933,7 +2938,7 @@ void RevisedSimplex::DisplayRevisedSimplexDebugInfo() {
}
VLOG(3) << output << ";";
const RevisedSimplexDictionary dictionary(this);
const RevisedSimplexDictionary dictionary(nullptr, this);
RowIndex r(0);
for (const SparseRow& row : dictionary) {
output.clear();

View File

@@ -228,7 +228,7 @@ class RevisedSimplex {
// Computes the dictionary B^-1*N on-the-fly row by row. Returns the resulting
// matrix as a vector of sparse rows so that it is easy to use it on the left
// side in the matrix multiplication. Runs in O(num_non_zeros_in_matrix).
RowMajorSparseMatrix ComputeDictionary();
RowMajorSparseMatrix ComputeDictionary(const SparseMatrixScaler* scaler);
private:
// Propagates parameters_ to all the other classes that need it.
@@ -799,8 +799,9 @@ class RevisedSimplexDictionary {
// RevisedSimplex cannot be passed const because we have to call a non-const
// method ComputeDictionary.
explicit RevisedSimplexDictionary(RevisedSimplex* revised_simplex)
: dictionary_(CHECK_NOTNULL(revised_simplex)->ComputeDictionary()),
RevisedSimplexDictionary(const SparseMatrixScaler* scaler,
RevisedSimplex* revised_simplex)
: dictionary_(CHECK_NOTNULL(revised_simplex)->ComputeDictionary(scaler)),
basis_vars_(CHECK_NOTNULL(revised_simplex)->GetBasisVector()) {}
ConstIterator begin() const { return dictionary_.begin(); }