simplify glop code

This commit is contained in:
Laurent Perron
2018-07-25 10:21:35 -07:00
parent f6d2b1dd32
commit 4007aa885f
3 changed files with 9 additions and 14 deletions

View File

@@ -89,9 +89,9 @@ Status EnteringVariable::PrimalChooseEnteringColumn(ColIndex* entering_col) {
Status EnteringVariable::DualChooseEnteringColumn(
const UpdateRow& update_row, Fractional cost_variation,
std::vector<ColIndex>* bound_flip_candidates, ColIndex* entering_col,
Fractional* pivot, Fractional* step) {
Fractional* step) {
GLOP_RETURN_ERROR_IF_NULL(entering_col);
GLOP_RETURN_ERROR_IF_NULL(pivot);
GLOP_RETURN_ERROR_IF_NULL(step);
const DenseRow& update_coefficient = update_row.GetCoefficients();
const DenseRow& reduced_costs = reduced_costs_->GetReducedCosts();
SCOPED_TIME_STAT(&stats_);
@@ -241,7 +241,6 @@ Status EnteringVariable::DualChooseEnteringColumn(
}
if (*entering_col == kInvalidCol) return Status::OK();
*pivot = update_coefficient[*entering_col];
// If the step is 0.0, we make sure the reduced cost is 0.0 so
// UpdateReducedCosts() will not take a step that goes in the wrong way (a few
@@ -266,9 +265,9 @@ Status EnteringVariable::DualChooseEnteringColumn(
Status EnteringVariable::DualPhaseIChooseEnteringColumn(
const UpdateRow& update_row, Fractional cost_variation,
ColIndex* entering_col, Fractional* pivot, Fractional* step) {
ColIndex* entering_col, Fractional* step) {
GLOP_RETURN_ERROR_IF_NULL(entering_col);
GLOP_RETURN_ERROR_IF_NULL(pivot);
GLOP_RETURN_ERROR_IF_NULL(step);
const DenseRow& update_coefficient = update_row.GetCoefficients();
const DenseRow& reduced_costs = reduced_costs_->GetReducedCosts();
SCOPED_TIME_STAT(&stats_);
@@ -365,8 +364,6 @@ Status EnteringVariable::DualPhaseIChooseEnteringColumn(
std::pop_heap(breakpoints_.begin(), breakpoints_.end());
breakpoints_.pop_back();
}
*pivot =
(*entering_col == kInvalidCol) ? 0.0 : update_coefficient[*entering_col];
return Status::OK();
}

View File

@@ -67,12 +67,11 @@ class EnteringVariable {
// Returns the index of the entering column given that we want to move along
// the "update" row vector in the direction given by the sign of
// cost_variation. Computes the smallest step that keeps the dual feasibility
// for all the columns. The pivot is the coefficient of the "update" vector at
// the entering column index.
// for all the columns.
Status DualChooseEnteringColumn(const UpdateRow& update_row,
Fractional cost_variation,
std::vector<ColIndex>* bound_flip_candidates,
ColIndex* entering_col, Fractional* pivot,
ColIndex* entering_col,
Fractional* step) MUST_USE_RESULT;
// Dual feasibility phase (i.e. phase I) ratio test.
@@ -82,7 +81,6 @@ class EnteringVariable {
Status DualPhaseIChooseEnteringColumn(const UpdateRow& update_row,
Fractional cost_variation,
ColIndex* entering_col,
Fractional* pivot,
Fractional* step) MUST_USE_RESULT;
// Sets the pricing parameters. This does not change the pricing rule.

View File

@@ -2553,7 +2553,6 @@ Status RevisedSimplex::DualMinimize(TimeLimit* time_limit) {
// Entering variable.
ColIndex entering_col;
Fractional entering_coeff;
Fractional ratio;
while (true) {
@@ -2670,11 +2669,11 @@ Status RevisedSimplex::DualMinimize(TimeLimit* time_limit) {
update_row_.ComputeUpdateRow(leaving_row);
if (feasibility_phase_) {
GLOP_RETURN_IF_ERROR(entering_variable_.DualPhaseIChooseEnteringColumn(
update_row_, cost_variation, &entering_col, &entering_coeff, &ratio));
update_row_, cost_variation, &entering_col, &ratio));
} else {
GLOP_RETURN_IF_ERROR(entering_variable_.DualChooseEnteringColumn(
update_row_, cost_variation, &bound_flip_candidates, &entering_col,
&entering_coeff, &ratio));
&ratio));
}
// No entering_col: Unbounded problem / Infeasible problem.
@@ -2708,6 +2707,7 @@ Status RevisedSimplex::DualMinimize(TimeLimit* time_limit) {
}
// If the coefficient is too small, we recompute the reduced costs.
const Fractional entering_coeff = update_row_.GetCoefficient(entering_col);
if (std::abs(entering_coeff) < parameters_.dual_small_pivot_threshold() &&
!reduced_costs_.AreReducedCostsPrecise()) {
VLOG(1) << "Trying not to pivot by " << entering_coeff;