fix tolerance bug

This commit is contained in:
Laurent Perron
2021-02-16 12:05:59 +01:00
parent 4861ac9f68
commit 7c2d4f8e18
2 changed files with 8 additions and 13 deletions

View File

@@ -357,9 +357,12 @@ message GlopParameters {
// The solver will stop as soon as it has proven that the objective is smaller
// than objective_lower_limit or greater than objective_upper_limit. Depending
// on the simplex algorithm (primal or dual) and the optimization direction,
// note that only one bound will be used at the time. The parameter
// solution_objective_gap_tolerance is used as a relative tolerance to improve
// the 'proven' guarantee.
// note that only one bound will be used at the time.
//
// Important: The solver does not add any tolerances to these values, and as
// soon as the objective (as computed by the solver, so with some imprecision)
// crosses one of these bounds (strictly), the search will stop. It is up to
// the client to add any tolerance if needed.
optional double objective_lower_limit = 40 [default = -inf];
optional double objective_upper_limit = 41 [default = inf];

View File

@@ -887,7 +887,6 @@ void RevisedSimplex::InitializeObjectiveLimit(const LinearProgram& lp) {
DCHECK_NE(0.0, objective_scaling_factor_);
// This sets dual_objective_limit_ and then primal_objective_limit_.
const Fractional tolerance = parameters_.solution_feasibility_tolerance();
for (const bool set_dual : {true, false}) {
// NOTE(user): If objective_scaling_factor_ is negative, the optimization
// direction was reversed (during preprocessing or inside revised simplex),
@@ -905,17 +904,10 @@ void RevisedSimplex::InitializeObjectiveLimit(const LinearProgram& lp) {
: parameters_.objective_upper_limit();
const Fractional shifted_limit =
limit / objective_scaling_factor_ - objective_offset_;
// The isfinite() test is there to avoid generating NaNs with clang in
// fast-math mode on iOS 9.3.i.
if (set_dual) {
dual_objective_limit_ = std::isfinite(shifted_limit)
? shifted_limit * (1.0 + tolerance)
: shifted_limit;
dual_objective_limit_ = shifted_limit;
} else {
primal_objective_limit_ = std::isfinite(shifted_limit)
? shifted_limit * (1.0 - tolerance)
: shifted_limit;
primal_objective_limit_ = shifted_limit;
}
}
}