From 5a127cbf3f9d85b7ad46a89839132f5db5ecb801 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Tue, 25 Oct 2022 20:30:23 +0200 Subject: [PATCH] fix bug in glop --- ortools/glop/parameters.proto | 4 ++-- ortools/glop/revised_simplex.cc | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ortools/glop/parameters.proto b/ortools/glop/parameters.proto index b1b4ce0763..2344ec5f27 100644 --- a/ortools/glop/parameters.proto +++ b/ortools/glop/parameters.proto @@ -30,8 +30,8 @@ message GlopParameters { // Supported algorithms for scaling: // EQUILIBRATION - progressive scaling by row and column norms until the // marginal difference passes below a threshold. - // LINEAR_PROGRAM - finding optimal scale factors using - // a linear program in the log scale. + // LINEAR_PROGRAM - EXPERIMENTAL: finding optimal scale factors using a linear + // program in the log scale. enum ScalingAlgorithm { DEFAULT = 0; EQUILIBRATION = 1; diff --git a/ortools/glop/revised_simplex.cc b/ortools/glop/revised_simplex.cc index 37f15af629..4db4073321 100644 --- a/ortools/glop/revised_simplex.cc +++ b/ortools/glop/revised_simplex.cc @@ -2867,6 +2867,9 @@ Status RevisedSimplex::PrimalMinimize(TimeLimit* time_limit) { if (refactorize) continue; if (step_length == kInfinity || step_length == -kInfinity) { + // On a validated input, we shouldn't have a length of -infinity even + // though it can be slightly negative in some settings. + DCHECK_NE(step_length, -kInfinity); if (!basis_factorization_.IsRefactorized() || !reduced_costs_.AreReducedCostsPrecise()) { VLOG(1) << "Infinite step length, double checking..."; @@ -2878,7 +2881,6 @@ Status RevisedSimplex::PrimalMinimize(TimeLimit* time_limit) { VLOG(1) << "Unbounded feasibility problem !?"; problem_status_ = ProblemStatus::ABNORMAL; } else { - VLOG(1) << "Unbounded problem."; problem_status_ = ProblemStatus::PRIMAL_UNBOUNDED; solution_primal_ray_.AssignToZero(num_cols_); for (RowIndex row(0); row < num_rows_; ++row) { @@ -2886,7 +2888,7 @@ Status RevisedSimplex::PrimalMinimize(TimeLimit* time_limit) { solution_primal_ray_[col] = -direction_[row]; } solution_primal_ray_[entering_col] = 1.0; - if (step_length == -kInfinity) { + if (reduced_cost > 0.0) { ChangeSign(&solution_primal_ray_); } }