OR-Tools  8.0
cbc_interface.cc
Go to the documentation of this file.
1 // Copyright 2010-2018 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 //
15 
16 #include <limits>
17 #include <memory>
18 #include <string>
19 #include <utility>
20 #include <vector>
21 
22 #include "absl/status/status.h"
23 #include "absl/strings/str_format.h"
25 #include "ortools/base/hash.h"
27 #include "ortools/base/logging.h"
28 #include "ortools/base/timer.h"
30 
31 #if defined(USE_CBC)
32 
33 #undef PACKAGE
34 #undef VERSION
35 #include "CbcConfig.h"
36 #include "CbcMessage.hpp"
37 #include "CbcModel.hpp"
38 #include "CoinModel.hpp"
39 #include "OsiClpSolverInterface.hpp"
40 
41 // Heuristics
42 
43 namespace operations_research {
44 
46  public:
47  // Constructor that takes a name for the underlying glpk solver.
48  explicit CBCInterface(MPSolver* const solver);
49  ~CBCInterface() override;
50 
51  // ----- Reset -----
52  void Reset() override;
53 
54  // Sets the optimization direction (min/max).
55  void SetOptimizationDirection(bool maximize) override;
56 
57  // ----- Parameters -----
58 
59  absl::Status SetNumThreads(int num_threads) override {
60  CHECK_GE(num_threads, 1);
61  num_threads_ = num_threads;
62  return absl::OkStatus();
63  }
64 
65  // ----- Solve -----
66  // Solve the problem using the parameter values specified.
67  MPSolver::ResultStatus Solve(const MPSolverParameters& param) override;
68 
69  // TODO(user): separate the solve from the model extraction.
70  virtual void ExtractModel() {}
71 
72  // Query problem type.
73  bool IsContinuous() const override { return false; }
74  bool IsLP() const override { return false; }
75  bool IsMIP() const override { return true; }
76 
77  // Modify bounds.
78  void SetVariableBounds(int var_index, double lb, double ub) override;
79  void SetVariableInteger(int var_index, bool integer) override;
80  void SetConstraintBounds(int row_index, double lb, double ub) override;
81 
82  // Add constraint incrementally.
83  void AddRowConstraint(MPConstraint* const ct) override;
84  // Add variable incrementally.
85  void AddVariable(MPVariable* const var) override;
86  // Change a coefficient in a constraint.
87  void SetCoefficient(MPConstraint* const constraint,
88  const MPVariable* const variable, double new_value,
89  double old_value) override {
91  }
92  // Clear a constraint from all its terms.
93  void ClearConstraint(MPConstraint* const constraint) override {
95  }
96 
97  // Change a coefficient in the linear objective.
98  void SetObjectiveCoefficient(const MPVariable* const variable,
99  double coefficient) override {
101  }
102  // Change the constant term in the linear objective.
103  void SetObjectiveOffset(double value) override { sync_status_ = MUST_RELOAD; }
104  // Clear the objective from all its terms.
105  void ClearObjective() override { sync_status_ = MUST_RELOAD; }
106 
107  // Number of simplex iterations
108  int64 iterations() const override;
109  // Number of branch-and-bound nodes. Only available for discrete problems.
110  int64 nodes() const override;
111  // Best objective bound. Only available for discrete problems.
112  double best_objective_bound() const override;
113 
114  // Returns the basis status of a row.
115  MPSolver::BasisStatus row_status(int constraint_index) const override {
116  LOG(FATAL) << "Basis status only available for continuous problems";
117  return MPSolver::FREE;
118  }
119  // Returns the basis status of a column.
120  MPSolver::BasisStatus column_status(int variable_index) const override {
121  LOG(FATAL) << "Basis status only available for continuous problems";
122  return MPSolver::FREE;
123  }
124 
125  void ExtractNewVariables() override {}
126  void ExtractNewConstraints() override {}
127  void ExtractObjective() override {}
128 
129  std::string SolverVersion() const override { return "Cbc " CBC_VERSION; }
130 
131  // TODO(user): Maybe we should expose the CbcModel build from osi_
132  // instead, but a new CbcModel is built every time Solve is called,
133  // so it is not possible right now.
134  void* underlying_solver() override { return reinterpret_cast<void*>(&osi_); }
135 
136  private:
137  // Reset best objective bound to +/- infinity depending on the
138  // optimization direction.
139  void ResetBestObjectiveBound();
140 
141  // Set all parameters in the underlying solver.
142  void SetParameters(const MPSolverParameters& param) override;
143  // Set each parameter in the underlying solver.
144  void SetRelativeMipGap(double value) override;
145  void SetPrimalTolerance(double value) override;
146  void SetDualTolerance(double value) override;
147  void SetPresolveMode(int value) override;
148  void SetScalingMode(int value) override;
149  void SetLpAlgorithm(int value) override;
150 
151  OsiClpSolverInterface osi_;
152  // TODO(user): remove and query number of iterations directly from CbcModel
153  int64 iterations_;
154  int64 nodes_;
155  double best_objective_bound_;
156  // Special way to handle the relative MIP gap parameter.
157  double relative_mip_gap_;
158  int num_threads_ = 1;
159 };
160 
161 // ----- Solver -----
162 
163 // Creates a LP/MIP instance with the specified name and minimization objective.
165  : MPSolverInterface(solver),
166  iterations_(0),
167  nodes_(0),
168  best_objective_bound_(-std::numeric_limits<double>::infinity()),
169  relative_mip_gap_(MPSolverParameters::kDefaultRelativeMipGap) {
170  osi_.setStrParam(OsiProbName, solver_->name_);
171  osi_.setObjSense(1);
172 }
173 
175 
176 // Reset the solver.
178  osi_.reset();
179  osi_.setObjSense(maximize_ ? -1 : 1);
180  osi_.setStrParam(OsiProbName, solver_->name_);
182 }
183 
184 void CBCInterface::ResetBestObjectiveBound() {
185  if (maximize_) {
186  best_objective_bound_ = std::numeric_limits<double>::infinity();
187  } else {
188  best_objective_bound_ = -std::numeric_limits<double>::infinity();
189  }
190 }
191 
195  osi_.setObjSense(maximize ? -1 : 1);
196  } else {
198  }
199 }
200 
201 namespace {
202 // CBC adds a "dummy" variable with index 0 to represent the objective offset.
203 int MPSolverVarIndexToCbcVarIndex(int var_index) { return var_index + 1; }
204 } // namespace
205 
206 void CBCInterface::SetVariableBounds(int var_index, double lb, double ub) {
209  osi_.setColBounds(MPSolverVarIndexToCbcVarIndex(var_index), lb, ub);
210  } else {
212  }
213 }
214 
215 void CBCInterface::SetVariableInteger(int var_index, bool integer) {
217  // TODO(user) : Check if this is actually a change.
219  if (integer) {
220  osi_.setInteger(MPSolverVarIndexToCbcVarIndex(var_index));
221  } else {
222  osi_.setContinuous(MPSolverVarIndexToCbcVarIndex(var_index));
223  }
224  } else {
226  }
227 }
228 
229 void CBCInterface::SetConstraintBounds(int index, double lb, double ub) {
232  osi_.setRowBounds(index, lb, ub);
233  } else {
235  }
236 }
237 
240 }
241 
244 }
245 
246 // Solve the LP/MIP. Returns true only if the optimal solution was revealed.
247 // Returns the status of the search.
249  // CBC requires unique variable and constraint names. By using Lookup*, we
250  // generate variable and constraint indices and ensure the duplicate name
251  // crash will happen here with a readable error message.
252  if (!solver_->variables_.empty()) {
253  solver_->LookupVariableOrNull(solver_->variables_[0]->name());
254  }
255  if (!solver_->constraints_.empty()) {
256  solver_->LookupConstraintOrNull(solver_->constraints_[0]->name());
257  }
258 
259  WallTimer timer;
260  timer.Start();
261 
262  // Note that CBC does not provide any incrementality.
265  Reset();
266  }
267 
268  // Special case if the model is empty since CBC is not able to
269  // handle this special case by itself.
270  if (solver_->variables_.empty() && solver_->constraints_.empty()) {
274  best_objective_bound_ = solver_->Objective().offset();
275  return result_status_;
276  }
277 
278  // Finish preparing the problem.
279  // Define variables.
280  switch (sync_status_) {
281  case MUST_RELOAD: {
282  Reset();
283  CoinModel build;
284  // Create dummy variable for objective offset.
285  build.addColumn(0, nullptr, nullptr, 1.0, 1.0,
286  solver_->Objective().offset(), "dummy", false);
287  const int nb_vars = solver_->variables_.size();
288  for (int i = 0; i < nb_vars; ++i) {
289  MPVariable* const var = solver_->variables_[i];
290  set_variable_as_extracted(i, true);
291  const double obj_coeff = solver_->Objective().GetCoefficient(var);
292  if (var->name().empty()) {
293  build.addColumn(0, nullptr, nullptr, var->lb(), var->ub(), obj_coeff,
294  nullptr, var->integer());
295  } else {
296  build.addColumn(0, nullptr, nullptr, var->lb(), var->ub(), obj_coeff,
297  var->name().c_str(), var->integer());
298  }
299  }
300 
301  // Define constraints.
302  int max_row_length = 0;
303  for (int i = 0; i < solver_->constraints_.size(); ++i) {
304  MPConstraint* const ct = solver_->constraints_[i];
306  if (ct->coefficients_.size() > max_row_length) {
307  max_row_length = ct->coefficients_.size();
308  }
309  }
310  std::unique_ptr<int[]> indices(new int[max_row_length]);
311  std::unique_ptr<double[]> coefs(new double[max_row_length]);
312 
313  for (int i = 0; i < solver_->constraints_.size(); ++i) {
314  MPConstraint* const ct = solver_->constraints_[i];
315  const int size = ct->coefficients_.size();
316  int j = 0;
317  for (const auto& entry : ct->coefficients_) {
318  const int index = MPSolverVarIndexToCbcVarIndex(entry.first->index());
319  indices[j] = index;
320  coefs[j] = entry.second;
321  j++;
322  }
323  if (ct->name().empty()) {
324  build.addRow(size, indices.get(), coefs.get(), ct->lb(), ct->ub());
325  } else {
326  build.addRow(size, indices.get(), coefs.get(), ct->lb(), ct->ub(),
327  ct->name().c_str());
328  }
329  }
330  osi_.loadFromCoinModel(build);
331  break;
332  }
333  case MODEL_SYNCHRONIZED: {
334  break;
335  }
336  case SOLUTION_SYNCHRONIZED: {
337  break;
338  }
339  }
340 
341  // Changing optimization direction through OSI so that the model file
342  // (written through OSI) has the correct optimization duration.
343  osi_.setObjSense(maximize_ ? -1 : 1);
344 
346  VLOG(1) << absl::StrFormat("Model built in %.3f seconds.", timer.Get());
347 
348  ResetBestObjectiveBound();
349 
350  // Solve
351  CbcModel model(osi_);
352 
353  // Set log level.
354  CoinMessageHandler message_handler;
355  model.passInMessageHandler(&message_handler);
356  if (quiet_) {
357  message_handler.setLogLevel(0, 0); // Coin messages
358  message_handler.setLogLevel(1, 0); // Clp messages
359  message_handler.setLogLevel(2, 0); // Presolve messages
360  message_handler.setLogLevel(3, 0); // Cgl messages
361  } else {
362  message_handler.setLogLevel(0, 1); // Coin messages
363  message_handler.setLogLevel(1, 1); // Clp messages
364  message_handler.setLogLevel(2, 1); // Presolve messages
365  message_handler.setLogLevel(3, 1); // Cgl messages
366  }
367 
368  // Time limit.
369  if (solver_->time_limit() != 0) {
370  VLOG(1) << "Setting time limit = " << solver_->time_limit() << " ms.";
371  model.setMaximumSeconds(solver_->time_limit_in_secs());
372  }
373 
374  // And solve.
375  timer.Restart();
376 
377  // Here we use the default function from the command-line CBC solver.
378  // This enables to activate all the features and get the same performance
379  // as the CBC stand-alone executable. The syntax is ugly, however.
380  SetParameters(param);
381  // Always turn presolve on (it's the CBC default and it consistently
382  // improves performance).
383  model.setTypePresolve(0);
384  // Special way to set the relative MIP gap parameter as it cannot be set
385  // through callCbc.
386  model.setAllowableFractionGap(relative_mip_gap_);
387  // NOTE: Trailing space is required to avoid buffer overflow in cbc.
388  int return_status =
389  num_threads_ == 1
390  ? callCbc("-solve ", model)
391  : callCbc(absl::StrCat("-threads ", num_threads_, " -solve "), model);
392  const int kBadReturnStatus = 777;
393  CHECK_NE(kBadReturnStatus, return_status); // Should never happen according
394  // to the CBC source
395 
396  VLOG(1) << absl::StrFormat("Solved in %.3f seconds.", timer.Get());
397 
398  // Check the status: optimal, infeasible, etc.
399  int tmp_status = model.status();
400 
401  VLOG(1) << "cbc result status: " << tmp_status;
402  /* Final status of problem
403  (info from cbc/.../CbcSolver.cpp,
404  See http://cs?q="cbc+status"+file:CbcSolver.cpp)
405  Some of these can be found out by is...... functions
406  -1 before branchAndBound
407  0 finished - check isProvenOptimal or isProvenInfeasible to see
408  if solution found
409  (or check value of best solution)
410  1 stopped - on maxnodes, maxsols, maxtime
411  2 difficulties so run was abandoned
412  (5 event user programmed event occurred)
413  */
414  switch (tmp_status) {
415  case 0:
416  // Order of tests counts; if model.isContinuousUnbounded() returns true,
417  // then so does model.isProvenInfeasible()!
418  if (model.isProvenOptimal()) {
420  } else if (model.isContinuousUnbounded()) {
422  } else if (model.isProvenInfeasible()) {
424  } else if (model.isAbandoned()) {
426  } else {
428  }
429  break;
430  case 1:
431  if (model.bestSolution() != nullptr) {
433  } else {
435  }
436  break;
437  default:
439  break;
440  }
441 
444  // Get the results
445  objective_value_ = model.getObjValue();
446  VLOG(1) << "objective=" << objective_value_;
447  const double* const values = model.bestSolution();
448  if (values != nullptr) {
449  // if optimal or feasible solution is found.
450  for (int i = 0; i < solver_->variables_.size(); ++i) {
451  MPVariable* const var = solver_->variables_[i];
452  const int var_index = MPSolverVarIndexToCbcVarIndex(var->index());
453  const double val = values[var_index];
454  var->set_solution_value(val);
455  VLOG(3) << var->name() << "=" << val;
456  }
457  } else {
458  VLOG(1) << "No feasible solution found.";
459  }
460  }
461 
462  iterations_ = model.getIterationCount();
463  nodes_ = model.getNodeCount();
464  best_objective_bound_ = model.getBestPossibleObjValue();
465  VLOG(1) << "best objective bound=" << best_objective_bound_;
466 
468 
469  return result_status_;
470 }
471 
472 // ------ Query statistics on the solution and the solve ------
473 
476  return iterations_;
477 }
478 
481  return nodes_;
482 }
483 
487  }
488  return best_objective_bound_;
489 }
490 
491 // ----- Parameters -----
492 
493 // The support for parameters in CBC is intentionally sparse. There is
494 // a memory leak in callCbc that prevents to pass parameters through
495 // it, so handling parameters would require an comprehensive rewrite
496 // of the code. I will improve the parameter support only if there is
497 // a relevant use case.
498 
499 void CBCInterface::SetParameters(const MPSolverParameters& param) {
500  SetCommonParameters(param);
501  SetMIPParameters(param);
502 }
503 
504 void CBCInterface::SetRelativeMipGap(double value) {
505  relative_mip_gap_ = value;
506 }
507 
508 void CBCInterface::SetPrimalTolerance(double value) {
509  // Skip the warning for the default value as it coincides with
510  // the default value in CBC.
513  }
514 }
515 
516 void CBCInterface::SetDualTolerance(double value) {
517  // Skip the warning for the default value as it coincides with
518  // the default value in CBC.
521  }
522 }
523 
524 void CBCInterface::SetPresolveMode(int value) {
525  switch (value) {
527  // CBC presolve is always on.
528  break;
529  }
530  default: {
532  }
533  }
534 }
535 
536 void CBCInterface::SetScalingMode(int value) {
538 }
539 
540 void CBCInterface::SetLpAlgorithm(int value) {
542 }
543 
545  return new CBCInterface(solver);
546 }
547 
548 } // namespace operations_research
549 #endif // #if defined(USE_CBC)
var
IntVar * var
Definition: expr_array.cc:1858
operations_research::CBCInterface::underlying_solver
void * underlying_solver() override
Definition: cbc_interface.cc:134
integral_types.h
operations_research::CBCInterface::ClearObjective
void ClearObjective() override
Definition: cbc_interface.cc:105
WallTimer::Get
double Get() const
Definition: timer.h:45
operations_research::MPSolverParameters::DUAL_TOLERANCE
@ DUAL_TOLERANCE
Advanced usage: tolerance for dual feasibility of basic solutions.
Definition: linear_solver.h:1373
operations_research::MPSolver::OPTIMAL
@ OPTIMAL
optimal.
Definition: linear_solver.h:427
operations_research::CBCInterface::ExtractModel
virtual void ExtractModel()
Definition: cbc_interface.cc:70
operations_research::MPSolverInterface::trivial_worst_objective_bound
double trivial_worst_objective_bound() const
Definition: linear_solver.cc:1682
operations_research::MPSolverParameters::LP_ALGORITHM
@ LP_ALGORITHM
Algorithm to solve linear programs.
Definition: linear_solver.h:1381
operations_research::MPSolver::Objective
const MPObjective & Objective() const
Returns the objective object.
Definition: linear_solver.h:414
operations_research::MPSolver::UNBOUNDED
@ UNBOUNDED
proven unbounded.
Definition: linear_solver.h:433
operations_research::MPObjective::GetCoefficient
double GetCoefficient(const MPVariable *const var) const
Gets the coefficient of a given variable in the objective.
Definition: linear_solver.cc:170
logging.h
operations_research::MPSolverInterface::quiet_
bool quiet_
Definition: linear_solver.h:1736
operations_research::MPSolver
This mathematical programming (MP) solver class is the main class though which users build and solve ...
Definition: linear_solver.h:177
operations_research::CBCInterface::best_objective_bound
double best_objective_bound() const override
Definition: cbc_interface.cc:484
operations_research::CBCInterface::SetVariableBounds
void SetVariableBounds(int var_index, double lb, double ub) override
Definition: cbc_interface.cc:206
value
int64 value
Definition: demon_profiler.cc:43
operations_research::MPSolverInterface::MODEL_SYNCHRONIZED
@ MODEL_SYNCHRONIZED
Definition: linear_solver.h:1523
operations_research::MPSolverInterface::CheckBestObjectiveBoundExists
virtual bool CheckBestObjectiveBoundExists() const
Definition: linear_solver.cc:1672
operations_research::MPSolver::LookupVariableOrNull
MPVariable * LookupVariableOrNull(const std::string &var_name) const
Looks up a variable by name, and returns nullptr if it does not exist.
Definition: linear_solver.cc:615
operations_research
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
Definition: dense_doubly_linked_list.h:21
operations_research::MPObjective::offset
double offset() const
Gets the constant term in the objective.
Definition: linear_solver.h:959
operations_research::MPSolverInterface::InvalidateSolutionSynchronization
void InvalidateSolutionSynchronization()
Definition: linear_solver.cc:1692
operations_research::MPSolverInterface
Definition: linear_solver.h:1514
operations_research::CBCInterface::column_status
MPSolver::BasisStatus column_status(int variable_index) const override
Definition: cbc_interface.cc:120
operations_research::MPSolver::ABNORMAL
@ ABNORMAL
abnormal, i.e., error of some kind.
Definition: linear_solver.h:435
WallTimer::Restart
void Restart()
Definition: timer.h:35
int64
int64_t int64
Definition: integral_types.h:34
index
int index
Definition: pack.cc:508
operations_research::CBCInterface::~CBCInterface
~CBCInterface() override
Definition: cbc_interface.cc:174
operations_research::MPSolverParameters
This class stores parameter settings for LP and MIP solvers.
Definition: linear_solver.h:1358
operations_research::MPConstraint
The class for constraints of a Mathematical Programming (MP) model.
Definition: linear_solver.h:1175
operations_research::CBCInterface::AddVariable
void AddVariable(MPVariable *const var) override
Definition: cbc_interface.cc:242
operations_research::MPSolverParameters::PRESOLVE_ON
@ PRESOLVE_ON
Presolve is on.
Definition: linear_solver.h:1393
operations_research::MPSolverInterface::objective_value_
double objective_value_
Definition: linear_solver.h:1733
operations_research::BuildCBCInterface
MPSolverInterface * BuildCBCInterface(MPSolver *const solver)
Definition: cbc_interface.cc:544
operations_research::MPSolverParameters::GetIntegerParam
int GetIntegerParam(MPSolverParameters::IntegerParam param) const
Returns the value of an integer parameter.
Definition: linear_solver.cc:1973
WallTimer::Start
void Start()
Definition: timer.h:31
operations_research::MPSolverInterface::ResetExtractionInformation
void ResetExtractionInformation()
Definition: linear_solver.cc:1640
operations_research::CBCInterface::CBCInterface
CBCInterface(MPSolver *const solver)
Definition: cbc_interface.cc:164
operations_research::CBCInterface::ClearConstraint
void ClearConstraint(MPConstraint *const constraint) override
Definition: cbc_interface.cc:93
operations_research::MPSolverInterface::kUnknownNumberOfIterations
static constexpr int64 kUnknownNumberOfIterations
Definition: linear_solver.h:1531
operations_research::CBCInterface::IsMIP
bool IsMIP() const override
Definition: cbc_interface.cc:75
operations_research::MPSolverInterface::solver_
MPSolver *const solver_
Definition: linear_solver.h:1718
operations_research::MPSolverInterface::SetUnsupportedDoubleParam
void SetUnsupportedDoubleParam(MPSolverParameters::DoubleParam param)
Definition: linear_solver.cc:1735
operations_research::MPSolver::NOT_SOLVED
@ NOT_SOLVED
not been solved yet.
Definition: linear_solver.h:439
operations_research::CBCInterface::ExtractNewVariables
void ExtractNewVariables() override
Definition: cbc_interface.cc:125
operations_research::MPSolverInterface::kUnknownNumberOfNodes
static constexpr int64 kUnknownNumberOfNodes
Definition: linear_solver.h:1534
timer.h
operations_research::MPSolverParameters::PRESOLVE
@ PRESOLVE
Advanced usage: presolve mode.
Definition: linear_solver.h:1379
operations_research::CBCInterface::SetObjectiveCoefficient
void SetObjectiveCoefficient(const MPVariable *const variable, double coefficient) override
Definition: cbc_interface.cc:98
operations_research::MPSolver::FREE
@ FREE
Definition: linear_solver.h:641
operations_research::MPSolverInterface::SOLUTION_SYNCHRONIZED
@ SOLUTION_SYNCHRONIZED
Definition: linear_solver.h:1526
operations_research::CBCInterface
Definition: cbc_interface.cc:45
operations_research::CBCInterface::AddRowConstraint
void AddRowConstraint(MPConstraint *const ct) override
Definition: cbc_interface.cc:238
operations_research::MPSolver::time_limit
int64 time_limit() const
Definition: linear_solver.h:777
operations_research::MPSolver::BasisStatus
BasisStatus
Advanced usage: possible basis status values for a variable and the slack variable of a linear constr...
Definition: linear_solver.h:640
operations_research::MPSolver::LookupConstraintOrNull
MPConstraint * LookupConstraintOrNull(const std::string &constraint_name) const
Looks up a constraint by name, and returns nullptr if it does not exist.
Definition: linear_solver.cc:624
operations_research::MPSolverParameters::kDefaultPrimalTolerance
static const double kDefaultPrimalTolerance
Definition: linear_solver.h:1441
operations_research::CBCInterface::iterations
int64 iterations() const override
Definition: cbc_interface.cc:474
ct
const Constraint * ct
Definition: demon_profiler.cc:42
operations_research::CBCInterface::SetNumThreads
absl::Status SetNumThreads(int num_threads) override
Definition: cbc_interface.cc:59
WallTimer
Definition: timer.h:23
operations_research::MPSolverInterface::SetUnsupportedIntegerParam
virtual void SetUnsupportedIntegerParam(MPSolverParameters::IntegerParam param)
Definition: linear_solver.cc:1739
operations_research::MPSolverParameters::INCREMENTALITY_OFF
@ INCREMENTALITY_OFF
Start solve from scratch.
Definition: linear_solver.h:1409
operations_research::MPSolverInterface::sync_status_
SynchronizationStatus sync_status_
Definition: linear_solver.h:1720
operations_research::CBCInterface::SolverVersion
std::string SolverVersion() const override
Definition: cbc_interface.cc:129
operations_research::MPSolver::time_limit_in_secs
double time_limit_in_secs() const
Definition: linear_solver.h:787
operations_research::MPSolverParameters::PRIMAL_TOLERANCE
@ PRIMAL_TOLERANCE
Advanced usage: tolerance for primal feasibility of basic solutions.
Definition: linear_solver.h:1371
operations_research::CBCInterface::SetConstraintBounds
void SetConstraintBounds(int row_index, double lb, double ub) override
Definition: cbc_interface.cc:229
operations_research::CBCInterface::ExtractObjective
void ExtractObjective() override
Definition: cbc_interface.cc:127
operations_research::MPSolver::ResultStatus
ResultStatus
The status of solving the problem.
Definition: linear_solver.h:425
operations_research::CBCInterface::SetObjectiveOffset
void SetObjectiveOffset(double value) override
Definition: cbc_interface.cc:103
model
GRBmodel * model
Definition: gurobi_interface.cc:195
operations_research::MPSolverInterface::SetMIPParameters
void SetMIPParameters(const MPSolverParameters &param)
Definition: linear_solver.cc:1728
operations_research::CBCInterface::Reset
void Reset() override
Definition: cbc_interface.cc:177
operations_research::CBCInterface::IsLP
bool IsLP() const override
Definition: cbc_interface.cc:74
operations_research::MPSolverParameters::kDefaultDualTolerance
static const double kDefaultDualTolerance
Definition: linear_solver.h:1442
operations_research::CBCInterface::IsContinuous
bool IsContinuous() const override
Definition: cbc_interface.cc:73
operations_research::CBCInterface::SetCoefficient
void SetCoefficient(MPConstraint *const constraint, const MPVariable *const variable, double new_value, double old_value) override
Definition: cbc_interface.cc:87
operations_research::MPSolverInterface::set_variable_as_extracted
void set_variable_as_extracted(int var_index, bool extracted)
Definition: linear_solver.h:1661
operations_research::MPSolverParameters::SCALING
@ SCALING
Advanced usage: enable or disable matrix scaling.
Definition: linear_solver.h:1385
coefficient
int64 coefficient
Definition: routing_search.cc:973
operations_research::CBCInterface::SetVariableInteger
void SetVariableInteger(int var_index, bool integer) override
Definition: cbc_interface.cc:215
operations_research::MPSolverParameters::INCREMENTALITY
@ INCREMENTALITY
Advanced usage: incrementality from one solve to the next.
Definition: linear_solver.h:1383
operations_research::MPVariable
The class for variables of a Mathematical Programming (MP) model.
Definition: linear_solver.h:1050
hash.h
linear_solver.h
A C++ wrapper that provides a simple and unified interface to several linear programming and mixed in...
operations_research::MPSolverInterface::SetCommonParameters
void SetCommonParameters(const MPSolverParameters &param)
Definition: linear_solver.cc:1707
operations_research::CBCInterface::nodes
int64 nodes() const override
Definition: cbc_interface.cc:479
operations_research::MPSolver::INFEASIBLE
@ INFEASIBLE
proven infeasible.
Definition: linear_solver.h:431
operations_research::CBCInterface::SetOptimizationDirection
void SetOptimizationDirection(bool maximize) override
Definition: cbc_interface.cc:192
operations_research::MPSolverInterface::MUST_RELOAD
@ MUST_RELOAD
Definition: linear_solver.h:1519
operations_research::MPSolverInterface::CheckSolutionIsSynchronized
bool CheckSolutionIsSynchronized() const
Definition: linear_solver.cc:1648
operations_research::CBCInterface::row_status
MPSolver::BasisStatus row_status(int constraint_index) const override
Definition: cbc_interface.cc:115
operations_research::MPSolverInterface::result_status_
MPSolver::ResultStatus result_status_
Definition: linear_solver.h:1723
operations_research::MPSolverInterface::maximize_
bool maximize_
Definition: linear_solver.h:1725
commandlineflags.h
operations_research::MPSolverInterface::set_constraint_as_extracted
void set_constraint_as_extracted(int ct_index, bool extracted)
Definition: linear_solver.h:1667
operations_research::CBCInterface::ExtractNewConstraints
void ExtractNewConstraints() override
Definition: cbc_interface.cc:126
operations_research::CBCInterface::Solve
MPSolver::ResultStatus Solve(const MPSolverParameters &param) override
Definition: cbc_interface.cc:248
operations_research::MPSolver::FEASIBLE
@ FEASIBLE
feasible, or stopped by limit.
Definition: linear_solver.h:429