16#include "absl/memory/memory.h"
17#include "ortools/glop/parameters.pb.h"
23#define ADD_LP_PREPROCESSOR(name) \
24 names.push_back(#name); \
25 lp_preprocessors.push_back(absl::make_unique<name>(&glop_params));
28 bool log_info,
const glop::GlopParameters& glop_params, MPModelProto*
model,
29 std::vector<std::unique_ptr<glop::Preprocessor>>* for_postsolve) {
33 if (!
model->general_constraint().empty()) {
34 return MPSolverResponseStatus::MPSOLVER_NOT_SOLVED;
38 const bool hint_is_present =
model->has_solution_hint();
39 const auto copy_of_hint =
model->solution_hint();
50 if (!hint_is_present) {
51 const std::string header =
52 "Running basic LP presolve, initial problem dimensions: ";
54 std::vector<std::string> names;
55 std::vector<std::unique_ptr<glop::Preprocessor>> lp_preprocessors;
67 for (
int i = 0; i < lp_preprocessors.size(); ++i) {
68 auto& preprocessor = lp_preprocessors[i];
69 preprocessor->UseInMipContext();
70 const bool need_postsolve = preprocessor->Run(&lp);
71 names[i].resize(header.size(),
' ');
77 return MPSolverResponseStatus::MPSOLVER_INFEASIBLE;
79 return MPSolverResponseStatus::MPSOLVER_NOT_SOLVED;
81 if (need_postsolve) for_postsolve->push_back(std::move(preprocessor));
86 if (!hint_is_present) {
88 absl::make_unique<glop::ShiftVariableBoundsPreprocessor>(&glop_params);
89 shift_bounds->UseInMipContext();
90 if (shift_bounds->Run(&lp)) {
91 for_postsolve->push_back(std::move(shift_bounds));
99 if (hint_is_present) {
100 *
model->mutable_solution_hint() = copy_of_hint;
103 return MPSolverResponseStatus::MPSOLVER_NOT_SOLVED;
106#undef ADD_LP_PREPROCESSOR
#define LOG_IF(severity, condition)
std::string GetDimensionString() const
void MPModelProtoToLinearProgram(const MPModelProto &input, LinearProgram *output)
void LinearProgramToMPModelProto(const LinearProgram &input, MPModelProto *output)
@ INFEASIBLE_OR_UNBOUNDED
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
MPSolverResponseStatus ApplyMipPresolveSteps(bool log_info, const glop::GlopParameters &glop_params, MPModelProto *model, std::vector< std::unique_ptr< glop::Preprocessor > > *for_postsolve)
#define ADD_LP_PREPROCESSOR(name)