diff --git a/ortools/glop/entering_variable.cc b/ortools/glop/entering_variable.cc index c5dfb2bda5..ae5be69da9 100644 --- a/ortools/glop/entering_variable.cc +++ b/ortools/glop/entering_variable.cc @@ -196,20 +196,22 @@ Status EnteringVariable::DualChooseEnteringColumn( } } - // Update harris_ratio. - harris_ratio = std::min(harris_ratio, - top.ratio + harris_tolerance / top.coeff_magnitude); - - // If the dual infeasibility is too high, the harris_ratio can be - // negative. In this case we set it to 0.0, allowing any infeasible - // position to enter the basis. This is quite important because its helps - // in the choice of a stable pivot. - harris_ratio = std::max(harris_ratio, 0.0); - // TODO(user): We want to maximize both the ratio (objective improvement) // and the coeff_magnitude (stable pivot), so we have to make some - // trade-offs. + // trade-offs. Investigate alternative strategies. if (top.coeff_magnitude >= best_coeff) { + // Update harris_ratio. Note that because we process ratio in order, the + // harris ratio can only get smaller if the coeff_magnitude is bigger + // than the one of the best coefficient. + harris_ratio = std::min( + harris_ratio, top.ratio + harris_tolerance / top.coeff_magnitude); + + // If the dual infeasibility is too high, the harris_ratio can be + // negative. In this case we set it to 0.0, allowing any infeasible + // position to enter the basis. This is quite important because its + // helps in the choice of a stable pivot. + harris_ratio = std::max(harris_ratio, 0.0); + if (top.coeff_magnitude == best_coeff && top.ratio == *step) { DCHECK_NE(*entering_col, kInvalidCol); equivalent_entering_choices_.push_back(top.col); diff --git a/ortools/glop/lp_solver.cc b/ortools/glop/lp_solver.cc index ed357b343e..a3090f445e 100644 --- a/ortools/glop/lp_solver.cc +++ b/ortools/glop/lp_solver.cc @@ -114,6 +114,8 @@ void LPSolver::SetParameters(const GlopParameters& parameters) { const GlopParameters& LPSolver::GetParameters() const { return parameters_; } +GlopParameters* LPSolver::GetMutableParameters() { return ¶meters_; } + ProblemStatus LPSolver::Solve(const LinearProgram& lp) { std::unique_ptr time_limit = TimeLimit::FromParameters(parameters_); diff --git a/ortools/glop/lp_solver.h b/ortools/glop/lp_solver.h index 313c805006..2aef632e13 100644 --- a/ortools/glop/lp_solver.h +++ b/ortools/glop/lp_solver.h @@ -34,6 +34,7 @@ class LPSolver { // See the proto for an extensive documentation. void SetParameters(const GlopParameters& parameters); const GlopParameters& GetParameters() const; + GlopParameters* GetMutableParameters(); // Solves the given linear program and returns the solve status. See the // ProblemStatus documentation for a description of the different values.