remove dead code; fix compilation with stats enables
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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<double> 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<is_entering_reduced_cost_positive>(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<is_entering_reduced_cost_positive>(e.row());
|
||||
if (ratio <= harris_ratio) {
|
||||
leaving_candidates->SetCoefficient(e.row(), ratio);
|
||||
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user