diff --git a/ortools/glop/lu_factorization.cc b/ortools/glop/lu_factorization.cc index b4bf50de8b..85dbf92e4d 100644 --- a/ortools/glop/lu_factorization.cc +++ b/ortools/glop/lu_factorization.cc @@ -42,15 +42,15 @@ void LuFactorization::Clear() { } Status LuFactorization::ComputeFactorization( - const CompactSparseMatrixView& compact_matrix) { + const CompactSparseMatrixView& matrix) { SCOPED_TIME_STAT(&stats_); Clear(); - if (compact_matrix.num_rows().value() != compact_matrix.num_cols().value()) { + if (matrix.num_rows().value() != matrix.num_cols().value()) { GLOP_RETURN_AND_LOG_ERROR(Status::ERROR_LU, "Not a square matrix!!"); } - GLOP_RETURN_IF_ERROR(markowitz_.ComputeLU(compact_matrix, &row_perm_, - &col_perm_, &lower_, &upper_)); + GLOP_RETURN_IF_ERROR( + markowitz_.ComputeLU(matrix, &row_perm_, &col_perm_, &lower_, &upper_)); inverse_col_perm_.PopulateFromInverse(col_perm_); inverse_row_perm_.PopulateFromInverse(row_perm_); ComputeTransposeUpper(); @@ -58,10 +58,10 @@ Status LuFactorization::ComputeFactorization( is_identity_factorization_ = false; IF_STATS_ENABLED({ - stats_.lu_fill_in.Add(GetFillInPercentage(compact_matrix)); + stats_.lu_fill_in.Add(GetFillInPercentage(matrix)); stats_.basis_num_entries.Add(matrix.num_entries().value()); }); - DCHECK(CheckFactorization(compact_matrix, Fractional(1e-6))); + DCHECK(CheckFactorization(matrix, Fractional(1e-6))); return Status::OK(); } diff --git a/ortools/glop/primal_edge_norms.cc b/ortools/glop/primal_edge_norms.cc index b48be4e60c..0fc6ea269f 100644 --- a/ortools/glop/primal_edge_norms.cc +++ b/ortools/glop/primal_edge_norms.cc @@ -167,8 +167,8 @@ void PrimalEdgeNorms::ComputeDirectionLeftInverse( // TODO(user): Refactorize if estimated accuracy above a threshold. IF_STATS_ENABLED(stats_.direction_left_inverse_accuracy.Add( - ScalarProduct(direction_left_inverse_.values, - matrix_.column(entering_col)) - + compact_matrix_.ColumnScalarProduct(entering_col, + direction_left_inverse_.values) - SquaredNorm(direction.values))); IF_STATS_ENABLED(stats_.direction_left_inverse_density.Add( Density(direction_left_inverse_.values))); diff --git a/ortools/glop/revised_simplex.cc b/ortools/glop/revised_simplex.cc index 420f77d483..f544a451a2 100644 --- a/ortools/glop/revised_simplex.cc +++ b/ortools/glop/revised_simplex.cc @@ -827,7 +827,6 @@ bool RevisedSimplex::InitializeBoundsAndTestIfUnchanged( SCOPED_TIME_STAT(&function_stats_); lower_bound_.resize(num_cols_, 0.0); upper_bound_.resize(num_cols_, 0.0); - bound_perturbation_.AssignToZero(num_cols_); // Variable bounds, for both non-slack and slack variables. bool bounds_are_unchanged = true; @@ -1436,25 +1435,6 @@ void RevisedSimplex::CorrectErrorsOnVariableValues() { << ", Primal residual |A.x - b| = " << variable_values_.ComputeMaximumPrimalResidual(); } - - // If we are doing too many degenerate iterations, we try to perturb the - // problem by extending each basic variable bound with a random value. See how - // bound_perturbation_ is used in ComputeHarrisRatioAndLeavingCandidates(). - // - // Note that the perturbation is currently only reset to zero at the end of - // the algorithm. - // - // TODO(user): This is currently disabled because the improvement is unclear. - if (/* DISABLES CODE */ false && - (!feasibility_phase_ && num_consecutive_degenerate_iterations_ >= 100)) { - VLOG(1) << "Perturbing the problem."; - const Fractional tolerance = parameters_.harris_tolerance_ratio() * - parameters_.primal_feasibility_tolerance(); - std::uniform_real_distribution dist(0, tolerance); - for (ColIndex col(0); col < num_cols_; ++col) { - bound_perturbation_[col] += dist(random_); - } - } } void RevisedSimplex::ComputeVariableValuesError() { @@ -1553,14 +1533,8 @@ Fractional RevisedSimplex::ComputeHarrisRatioAndLeavingCandidates( for (const auto e : direction_) { const Fractional magnitude = std::abs(e.coefficient()); if (magnitude <= threshold) continue; - Fractional ratio = GetRatio(e.row()); - // TODO(user): The perturbation is currently disabled, so no need to test - // anything here. - if (false && ratio < 0.0) { - // If the variable is already pass its bound, we use the perturbed version - // of the bound (if bound_perturbation_[basis_[row]] is not zero). - ratio += std::abs(bound_perturbation_[basis_[e.row()]] / e.coefficient()); - } + const Fractional ratio = + GetRatio(e.row()); if (ratio <= harris_ratio) { leaving_candidates->SetCoefficient(e.row(), ratio); diff --git a/ortools/glop/revised_simplex.h b/ortools/glop/revised_simplex.h index 7511c47a8a..be100e9755 100644 --- a/ortools/glop/revised_simplex.h +++ b/ortools/glop/revised_simplex.h @@ -627,11 +627,6 @@ class RevisedSimplex { DenseRow lower_bound_; DenseRow upper_bound_; - // The bound perturbation to be used for basic variable that are slightly - // outside their bounds. This contains small values that are non-zero only if - // the primal simplex ran into many degenerate iterations. - DenseRow bound_perturbation_; - // Used in dual phase I to keep track of the non-basic dual infeasible // columns and their sign of infeasibility (+1 or -1). DenseRow dual_infeasibility_improvement_direction_; diff --git a/ortools/glop/update_row.cc b/ortools/glop/update_row.cc index ca56f55e7e..9a44e41ce0 100644 --- a/ortools/glop/update_row.cc +++ b/ortools/glop/update_row.cc @@ -72,7 +72,7 @@ void UpdateRow::ComputeUnitRowLeftInverse(RowIndex leaving_row) { unit_row_left_inverse_.values) - 1.0)); IF_STATS_ENABLED(stats_.unit_row_left_inverse_density.Add( - Density(unit_row_left_inverse_.values()))); + Density(unit_row_left_inverse_.values))); } void UpdateRow::ComputeUpdateRow(RowIndex leaving_row) {