diff --git a/ortools/glop/lp_solver.cc b/ortools/glop/lp_solver.cc index 094e7f2e72..4a8e097b21 100644 --- a/ortools/glop/lp_solver.cc +++ b/ortools/glop/lp_solver.cc @@ -655,7 +655,10 @@ bool LPSolver::IsProblemSolutionConsistent( ++num_basic_variables; break; case ConstraintStatus::FIXED_VALUE: - if (lb != ub) { + // Exactly the same remark as for the VariableStatus::FIXED_VALUE case + // above. Because of precision error, this can happen when the + // difference between the two bounds is small and not just exactly zero. + if (ub - lb > 1e-12) { LogConstraintStatusError(row, status, lb, ub); return false; } diff --git a/ortools/glop/revised_simplex.cc b/ortools/glop/revised_simplex.cc index 6a960fb434..1814664c11 100644 --- a/ortools/glop/revised_simplex.cc +++ b/ortools/glop/revised_simplex.cc @@ -2026,10 +2026,9 @@ void RevisedSimplex::DualPhaseIUpdatePriceOnReducedCostChange( for (ColIndex col : cols) { const Fractional reduced_cost = reduced_costs[col]; const Fractional sign = - (can_increase.IsSet(col) && reduced_cost < -tolerance) - ? 1.0 - : (can_decrease.IsSet(col) && reduced_cost > tolerance) ? -1.0 - : 0.0; + (can_increase.IsSet(col) && reduced_cost < -tolerance) ? 1.0 + : (can_decrease.IsSet(col) && reduced_cost > tolerance) ? -1.0 + : 0.0; if (sign != dual_infeasibility_improvement_direction_[col]) { if (sign == 0.0) { --num_dual_infeasible_positions_; @@ -2275,9 +2274,9 @@ Status RevisedSimplex::UpdateAndPivot(ColIndex entering_col, const VariableStatus leaving_variable_status = lower_bound_[leaving_col] == upper_bound_[leaving_col] ? VariableStatus::FIXED_VALUE - : target_bound == lower_bound_[leaving_col] - ? VariableStatus::AT_LOWER_BOUND - : VariableStatus::AT_UPPER_BOUND; + : target_bound == lower_bound_[leaving_col] + ? VariableStatus::AT_LOWER_BOUND + : VariableStatus::AT_UPPER_BOUND; if (variable_values_.Get(leaving_col) != target_bound) { ratio_test_stats_.bound_shift.Add(variable_values_.Get(leaving_col) - target_bound);