From 347186ecaec3e612c7dd20876eceb2924888d37f Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Tue, 16 May 2017 10:43:33 +0200 Subject: [PATCH] sync with internal code; minor changes --- ortools/base/file.cc | 2 +- ortools/linear_solver/linear_solver.cc | 12 ++++++------ ortools/linear_solver/linear_solver.h | 2 ++ ortools/linear_solver/linear_solver.proto | 3 +-- ortools/lp_data/lp_utils.h | 5 +++++ 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ortools/base/file.cc b/ortools/base/file.cc index eb5a4f8e48..d8f36b4374 100644 --- a/ortools/base/file.cc +++ b/ortools/base/file.cc @@ -13,6 +13,7 @@ #include #include +#include "ortools/base/join.h" #if defined(_MSC_VER) #include #define access _access @@ -27,7 +28,6 @@ #include "ortools/base/file.h" #include "ortools/base/logging.h" -#include "ortools/base/join.h" File::File(FILE* const f_des, const std::string& name) : f_(f_des), name_(name) {} diff --git a/ortools/linear_solver/linear_solver.cc b/ortools/linear_solver/linear_solver.cc index efa06a2ca5..111117cdba 100644 --- a/ortools/linear_solver/linear_solver.cc +++ b/ortools/linear_solver/linear_solver.cc @@ -312,12 +312,12 @@ void MPVariable::SetInteger(bool integer) { } } -// ----- Version ----- +// ----- Interface shortcuts ----- + +bool MPSolver::IsMIP() const { return interface_->IsMIP(); } std::string MPSolver::SolverVersion() const { return interface_->SolverVersion(); } -// ---- Underlying solver ---- - void* MPSolver::underlying_solver() { return interface_->underlying_solver(); } // ---- Solver-specific parameters ---- @@ -920,9 +920,9 @@ MPSolver::ResultStatus MPSolver::Solve(const MPSolverParameters& param) { MPSolver::ResultStatus status = interface_->Solve(param); if (FLAGS_verify_solution) { - if (status != MPSolver::OPTIMAL) { - VLOG(1) << "--verify_solution enabled, but the solver did not find an" - << " optimal solution: skipping the verification."; + if (status != MPSolver::OPTIMAL && status != MPSolver::FEASIBLE) { + VLOG(1) << "--verify_solution enabled, but the solver did not find a" + << " solution: skipping the verification."; } else if (!VerifySolution( param.GetDoubleParam(MPSolverParameters::PRIMAL_TOLERANCE), FLAGS_log_verification_errors)) { diff --git a/ortools/linear_solver/linear_solver.h b/ortools/linear_solver/linear_solver.h index 03a371c879..fb5dc7e3f8 100644 --- a/ortools/linear_solver/linear_solver.h +++ b/ortools/linear_solver/linear_solver.h @@ -216,6 +216,8 @@ class MPSolver { // targets that you linked). static bool SupportsProblemType(OptimizationProblemType problem_type); + bool IsMIP() const; + std::string Name() const { return name_; // Set at construction. } diff --git a/ortools/linear_solver/linear_solver.proto b/ortools/linear_solver/linear_solver.proto index 8d1105e826..54cb0f4d62 100644 --- a/ortools/linear_solver/linear_solver.proto +++ b/ortools/linear_solver/linear_solver.proto @@ -47,7 +47,6 @@ package operations_research; // MPVariableProto furthermore stores: // - The coefficient of the variable in the objective. // - Whether the variable is integer. -// - Whether the variable domain is {0} union [lower_bound, upper_bound]. message MPVariableProto { // lower_bound must be <= upper_bound. optional double lower_bound = 1 [default = -inf]; @@ -97,7 +96,7 @@ message MPConstraintProto { optional bool is_lazy = 5 [default = false]; } -// This message encode a partial (or full) assignment of the variables of a +// This message encodes a partial (or full) assignment of the variables of a // MPModelProto problem. The indices in var_index should be unique and valid // variable indices of the associated problem. message PartialVariableAssignment { diff --git a/ortools/lp_data/lp_utils.h b/ortools/lp_data/lp_utils.h index 680916d112..d0c3f5c680 100644 --- a/ortools/lp_data/lp_utils.h +++ b/ortools/lp_data/lp_utils.h @@ -310,6 +310,11 @@ class SumWithOneMissing { ++num_infinities_; } + Fractional Sum() const { + if (num_infinities_ > 0) return Infinity(); + return sum_.Value(); + } + Fractional SumWithout(Fractional x) const { if (IsFinite(x)) { if (num_infinities_ > 0) return Infinity();