[LP] change default tolerance on verify solution; add missing base include
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "google/protobuf/text_format.h"
|
||||
#include "ortools/base/commandlineflags.h"
|
||||
#include "ortools/base/file.h"
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "ortools/base/commandlineflags.h"
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "ortools/base/hash.h"
|
||||
#include "ortools/base/integral_types.h"
|
||||
#include "ortools/base/logging.h"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "ortools/base/commandlineflags.h"
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
@@ -64,6 +65,7 @@
|
||||
#include "ortools/linear_solver/gurobi_proto_solver.h"
|
||||
#include "ortools/linear_solver/linear_solver.h"
|
||||
#include "ortools/linear_solver/linear_solver_callback.h"
|
||||
#include "ortools/util/time_limit.h"
|
||||
|
||||
ABSL_FLAG(int, num_gurobi_threads, 4,
|
||||
"Number of threads available for Gurobi.");
|
||||
@@ -84,7 +86,6 @@ class GurobiInterface : public MPSolverInterface {
|
||||
MPSolver::ResultStatus Solve(const MPSolverParameters& param) override;
|
||||
absl::optional<MPSolutionResponse> DirectlySolveProto(
|
||||
const MPModelRequest& request, std::atomic<bool>* interrupt) override;
|
||||
|
||||
// Writes the model.
|
||||
void Write(const std::string& filename) override;
|
||||
|
||||
|
||||
@@ -157,7 +157,10 @@ PROTO2_RETURN(
|
||||
* that.
|
||||
*/
|
||||
bool loadSolutionFromProto(const MPSolutionResponse& response) {
|
||||
return $self->LoadSolutionFromProto(response).ok();
|
||||
const absl::Status status =
|
||||
$self->LoadSolutionFromProto(response);
|
||||
LOG_IF(ERROR, !status.ok()) << "LoadSolutionFromProto() failed: " << status;
|
||||
return status.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "ortools/base/integral_types.h"
|
||||
#include "ortools/base/logging.h"
|
||||
#include "ortools/base/map_util.h"
|
||||
#include "ortools/base/status_macros.h"
|
||||
#include "ortools/base/stl_util.h"
|
||||
#include "ortools/base/threadpool.h"
|
||||
#include "ortools/linear_solver/linear_solver.pb.h"
|
||||
@@ -48,6 +47,7 @@
|
||||
#include "ortools/linear_solver/model_validator.h"
|
||||
#include "ortools/port/file.h"
|
||||
#include "ortools/util/fp_utils.h"
|
||||
#include "ortools/util/time_limit.h"
|
||||
|
||||
ABSL_FLAG(bool, verify_solution, false,
|
||||
"Systematically verify the solution when calling Solve()"
|
||||
@@ -240,7 +240,7 @@ void MPObjective::SetOptimizationDirection(bool maximize) {
|
||||
// Note(user): The maximize_ bool would more naturally belong to the
|
||||
// MPObjective, but it actually has to be a member of MPSolverInterface,
|
||||
// because some implementations (such as GLPK) need that bool for the
|
||||
// MPSolverInterface constructor, i.e at a time when the MPObjective is not
|
||||
// MPSolverInterface constructor, i.e. at a time when the MPObjective is not
|
||||
// constructed yet (MPSolverInterface is always built before MPObjective
|
||||
// when a new MPSolver is constructed).
|
||||
interface_->maximize_ = maximize;
|
||||
|
||||
@@ -144,6 +144,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/port.h"
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "absl/flags/usage.h"
|
||||
@@ -606,7 +607,7 @@ class MPSolver {
|
||||
*/
|
||||
absl::Status LoadSolutionFromProto(
|
||||
const MPSolutionResponse& response,
|
||||
double tolerance = kDefaultPrimalTolerance);
|
||||
double tolerance = std::numeric_limits<double>::infinity());
|
||||
|
||||
/**
|
||||
* Resets values of out of bound variables to the corresponding bound and
|
||||
|
||||
@@ -98,7 +98,7 @@ from ortools.linear_solver.linear_solver_natural_api import VariableExpr
|
||||
// Change the API of LoadSolutionFromProto() to simply return a boolean.
|
||||
bool LoadSolutionFromProto(
|
||||
const operations_research::MPSolutionResponse& response,
|
||||
double tolerance = operations_research::MPSolverParameters::kDefaultPrimalTolerance) {
|
||||
double tolerance = std::numeric_limits<double>::infinity()) {
|
||||
const absl::Status status =
|
||||
$self->LoadSolutionFromProto(response, tolerance);
|
||||
LOG_IF(ERROR, !status.ok()) << "LoadSolutionFromProto() failed: " << status;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "ortools/base/hash.h"
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
Reference in New Issue
Block a user