@@ -325,7 +325,7 @@ Fractional ProblemObjectiveValue(const LinearProgram& lp, Fractional value) {
325325// Returns the allowed error magnitude for something that should evaluate to
326326// value under the given tolerance.
327327Fractional AllowedError (Fractional tolerance, Fractional value) {
328- return tolerance * std::max (1.0 , std::abs (value));
328+ return tolerance * std::max (Fractional ( 1.0 ) , std::abs (value));
329329}
330330} // namespace
331331
@@ -492,15 +492,15 @@ bool LPSolver::IsOptimalSolutionOnFacet(const LinearProgram& lp) {
492492 // primal values.
493493 // TODO(user): investigate whether to use the tolerances defined in
494494 // parameters.proto.
495- const double kReducedCostTolerance = 1e-9 ;
496- const double kBoundTolerance = 1e-7 ;
495+ const Fractional kReducedCostTolerance = 1e-9 ;
496+ const Fractional kBoundTolerance = 1e-7 ;
497497 const ColIndex num_cols = lp.num_variables ();
498498 for (ColIndex col (0 ); col < num_cols; ++col) {
499499 if (variable_statuses_[col] == VariableStatus::FIXED_VALUE) continue ;
500500 const Fractional lower_bound = lp.variable_lower_bounds ()[col];
501501 const Fractional upper_bound = lp.variable_upper_bounds ()[col];
502502 const Fractional value = primal_values_[col];
503- if (AreWithinAbsoluteTolerance (reduced_costs_[col], 0.0 ,
503+ if (AreWithinAbsoluteTolerance (reduced_costs_[col], Fractional ( 0.0 ) ,
504504 kReducedCostTolerance ) &&
505505 (AreWithinAbsoluteTolerance (value, lower_bound, kBoundTolerance ) ||
506506 AreWithinAbsoluteTolerance (value, upper_bound, kBoundTolerance ))) {
@@ -513,7 +513,7 @@ bool LPSolver::IsOptimalSolutionOnFacet(const LinearProgram& lp) {
513513 const Fractional lower_bound = lp.constraint_lower_bounds ()[row];
514514 const Fractional upper_bound = lp.constraint_upper_bounds ()[row];
515515 const Fractional activity = constraint_activities_[row];
516- if (AreWithinAbsoluteTolerance (dual_values_[row], 0.0 ,
516+ if (AreWithinAbsoluteTolerance (dual_values_[row], Fractional ( 0.0 ) ,
517517 kReducedCostTolerance ) &&
518518 (AreWithinAbsoluteTolerance (activity, lower_bound, kBoundTolerance ) ||
519519 AreWithinAbsoluteTolerance (activity, upper_bound, kBoundTolerance ))) {
@@ -739,7 +739,8 @@ bool LPSolver::IsProblemSolutionConsistent(
739739 case VariableStatus::AT_UPPER_BOUND:
740740 // TODO(user): revert to an exact comparison once the bug causing this
741741 // to fail has been fixed.
742- if (!AreWithinAbsoluteTolerance (value, ub, 1e-7 ) || lb == ub) {
742+ if (!AreWithinAbsoluteTolerance (value, ub, Fractional (1e-7 )) ||
743+ lb == ub) {
743744 LogVariableStatusError (col, value, status, lb, ub);
744745 return false ;
745746 }
@@ -1002,7 +1003,7 @@ double LPSolver::ComputeMaxExpectedObjectiveError(const LinearProgram& lp) {
10021003
10031004double LPSolver::ComputePrimalValueInfeasibility (const LinearProgram& lp,
10041005 bool * is_too_large) {
1005- double infeasibility = 0.0 ;
1006+ Fractional infeasibility = 0.0 ;
10061007 const Fractional tolerance = parameters_.solution_feasibility_tolerance ();
10071008 const ColIndex num_cols = lp.num_variables ();
10081009 for (ColIndex col (0 ); col < num_cols; ++col) {
@@ -1032,7 +1033,7 @@ double LPSolver::ComputePrimalValueInfeasibility(const LinearProgram& lp,
10321033
10331034double LPSolver::ComputeActivityInfeasibility (const LinearProgram& lp,
10341035 bool * is_too_large) {
1035- double infeasibility = 0.0 ;
1036+ Fractional infeasibility = 0.0 ;
10361037 int num_problematic_rows (0 );
10371038 const RowIndex num_rows = lp.num_constraints ();
10381039 const Fractional tolerance = parameters_.solution_feasibility_tolerance ();
@@ -1085,7 +1086,7 @@ double LPSolver::ComputeDualValueInfeasibility(const LinearProgram& lp,
10851086 bool * is_too_large) {
10861087 const Fractional allowed_error = parameters_.solution_feasibility_tolerance ();
10871088 const Fractional optimization_sign = lp.IsMaximizationProblem () ? -1.0 : 1.0 ;
1088- double infeasibility = 0.0 ;
1089+ Fractional infeasibility = 0.0 ;
10891090 const RowIndex num_rows = lp.num_constraints ();
10901091 for (RowIndex row (0 ); row < num_rows; ++row) {
10911092 const Fractional dual_value = dual_values_[row];
@@ -1108,7 +1109,7 @@ double LPSolver::ComputeDualValueInfeasibility(const LinearProgram& lp,
11081109double LPSolver::ComputeReducedCostInfeasibility (const LinearProgram& lp,
11091110 bool * is_too_large) {
11101111 const Fractional optimization_sign = lp.IsMaximizationProblem () ? -1.0 : 1.0 ;
1111- double infeasibility = 0.0 ;
1112+ Fractional infeasibility = 0.0 ;
11121113 const ColIndex num_cols = lp.num_variables ();
11131114 const Fractional tolerance = parameters_.solution_feasibility_tolerance ();
11141115 for (ColIndex col (0 ); col < num_cols; ++col) {
0 commit comments