OR-Tools  8.0
clp_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 <algorithm>
17 #include <memory>
18 #include <string>
19 #include <vector>
20 
21 #include "absl/memory/memory.h"
22 #include "absl/strings/match.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_CLP) || defined(USE_CBC)
32 
33 #undef PACKAGE
34 #undef VERSION
35 #include "ClpConfig.h"
36 #include "ClpMessage.hpp"
37 #include "ClpSimplex.hpp"
38 #include "CoinBuild.hpp"
39 
40 namespace operations_research {
41 
43  public:
44  // Constructor that takes a name for the underlying CLP solver.
45  explicit CLPInterface(MPSolver* const solver);
46  ~CLPInterface() override;
47 
48  // Sets the optimization direction (min/max).
49  void SetOptimizationDirection(bool maximize) override;
50 
51  // ----- Solve -----
52  // Solve the problem using the parameter values specified.
53  MPSolver::ResultStatus Solve(const MPSolverParameters& param) override;
54 
55  // ----- Model modifications and extraction -----
56  // Resets extracted model
57  void Reset() override;
58 
59  // Modify bounds.
60  void SetVariableBounds(int var_index, double lb, double ub) override;
61  void SetVariableInteger(int var_index, bool integer) override;
62  void SetConstraintBounds(int row_index, double lb, double ub) override;
63 
64  // Add constraint incrementally.
65  void AddRowConstraint(MPConstraint* const ct) override;
66  // Add variable incrementally.
67  void AddVariable(MPVariable* const var) override;
68  // Change a coefficient in a constraint.
69  void SetCoefficient(MPConstraint* const constraint,
70  const MPVariable* const variable, double new_value,
71  double old_value) override;
72  // Clear a constraint from all its terms.
73  void ClearConstraint(MPConstraint* const constraint) override;
74 
75  // Change a coefficient in the linear objective.
76  void SetObjectiveCoefficient(const MPVariable* const variable,
77  double coefficient) override;
78  // Change the constant term in the linear objective.
79  void SetObjectiveOffset(double offset) override;
80  // Clear the objective from all its terms.
81  void ClearObjective() override;
82 
83  // ------ Query statistics on the solution and the solve ------
84  // Number of simplex iterations
85  int64 iterations() const override;
86  // Number of branch-and-bound nodes. Only available for discrete problems.
87  int64 nodes() const override;
88  // Best objective bound. Only available for discrete problems.
89  double best_objective_bound() const override;
90 
91  // Returns the basis status of a row.
92  MPSolver::BasisStatus row_status(int constraint_index) const override;
93  // Returns the basis status of a column.
94  MPSolver::BasisStatus column_status(int variable_index) const override;
95 
96  // ----- Misc -----
97  // Query problem type.
98  bool IsContinuous() const override { return true; }
99  bool IsLP() const override { return true; }
100  bool IsMIP() const override { return false; }
101 
102  void ExtractNewVariables() override;
103  void ExtractNewConstraints() override;
104  void ExtractObjective() override;
105 
106  std::string SolverVersion() const override { return "Clp " CLP_VERSION; }
107 
108  void* underlying_solver() override {
109  return reinterpret_cast<void*>(clp_.get());
110  }
111 
112  private:
113  // Create dummy variable to be able to create empty constraints.
114  void CreateDummyVariableForEmptyConstraints();
115 
116  // Set all parameters in the underlying solver.
117  void SetParameters(const MPSolverParameters& param) override;
118  // Reset to their default value the parameters for which CLP has a
119  // stateful API. To be called after the solve so that the next solve
120  // starts from a clean parameter state.
121  void ResetParameters();
122  // Set each parameter in the underlying solver.
123  void SetRelativeMipGap(double value) override;
124  void SetPrimalTolerance(double value) override;
125  void SetDualTolerance(double value) override;
126  void SetPresolveMode(int value) override;
127  void SetScalingMode(int value) override;
128  void SetLpAlgorithm(int value) override;
129 
130  // Transforms basis status from CLP enum to MPSolver::BasisStatus.
131  MPSolver::BasisStatus TransformCLPBasisStatus(
132  ClpSimplex::Status clp_basis_status) const;
133 
134  std::unique_ptr<ClpSimplex> clp_; // TODO(user) : remove pointer.
135  std::unique_ptr<ClpSolve> options_; // For parameter setting.
136 };
137 
138 // ----- Solver -----
139 
140 // Creates a LP/MIP instance with the specified name and minimization objective.
142  : MPSolverInterface(solver), clp_(new ClpSimplex), options_(new ClpSolve) {
143  clp_->setStrParam(ClpProbName, solver_->name_);
144  clp_->setOptimizationDirection(1);
145 }
146 
148 
150  clp_ = absl::make_unique<ClpSimplex>();
151  clp_->setOptimizationDirection(maximize_ ? -1 : 1);
153 }
154 
155 // ------ Model modifications and extraction -----
156 
157 namespace {
158 // Variable indices are shifted by 1 internally because of the dummy "objective
159 // offset" variable (with internal index 0).
160 int MPSolverVarIndexToClpVarIndex(int var_index) { return var_index + 1; }
161 } // namespace
162 
163 // Not cached
166  clp_->setOptimizationDirection(maximize ? -1 : 1);
167 }
168 
169 void CLPInterface::SetVariableBounds(int var_index, double lb, double ub) {
171  if (variable_is_extracted(var_index)) {
172  // Not cached if the variable has been extracted
173  DCHECK_LT(var_index, last_variable_index_);
174  clp_->setColumnBounds(MPSolverVarIndexToClpVarIndex(var_index), lb, ub);
175  } else {
177  }
178 }
179 
180 // Ignore as CLP does not solve models with integer variables
181 void CLPInterface::SetVariableInteger(int var_index, bool integer) {}
182 
183 void CLPInterface::SetConstraintBounds(int index, double lb, double ub) {
186  // Not cached if the row has been extracted
187  DCHECK_LT(index, last_constraint_index_);
188  clp_->setRowBounds(index, lb, ub);
189  } else {
191  }
192 }
193 
195  const MPVariable* const variable,
196  double new_value, double old_value) {
198  if (constraint_is_extracted(constraint->index()) &&
199  variable_is_extracted(variable->index())) {
200  // The modification of the coefficient for an extracted row and
201  // variable is not cached.
202  DCHECK_LE(constraint->index(), last_constraint_index_);
203  DCHECK_LE(variable->index(), last_variable_index_);
204  clp_->modifyCoefficient(constraint->index(),
205  MPSolverVarIndexToClpVarIndex(variable->index()),
206  new_value);
207  } else {
208  // The modification of an unextracted row or variable is cached
209  // and handled in ExtractModel.
211  }
212 }
213 
214 // Not cached
217  // Constraint may not have been extracted yet.
218  if (!constraint_is_extracted(constraint->index())) return;
219  for (const auto& entry : constraint->coefficients_) {
220  DCHECK(variable_is_extracted(entry.first->index()));
221  clp_->modifyCoefficient(constraint->index(),
222  MPSolverVarIndexToClpVarIndex(entry.first->index()),
223  0.0);
224  }
225 }
226 
227 // Cached
229  double coefficient) {
231  if (variable_is_extracted(variable->index())) {
232  clp_->setObjectiveCoefficient(
233  MPSolverVarIndexToClpVarIndex(variable->index()), coefficient);
234  } else {
236  }
237 }
238 
239 // Cached
240 void CLPInterface::SetObjectiveOffset(double offset) {
241  // Constant term. Use -offset instead of +offset because CLP does
242  // not follow conventions.
244  clp_->setObjectiveOffset(-offset);
245 }
246 
247 // Clear objective of all its terms.
250  // Clear linear terms
251  for (const auto& entry : solver_->objective_->coefficients_) {
252  const int mpsolver_var_index = entry.first->index();
253  // Variable may have not been extracted yet.
254  if (!variable_is_extracted(mpsolver_var_index)) {
255  DCHECK_NE(MODEL_SYNCHRONIZED, sync_status_);
256  } else {
257  clp_->setObjectiveCoefficient(
258  MPSolverVarIndexToClpVarIndex(mpsolver_var_index), 0.0);
259  }
260  }
261  // Clear constant term.
262  clp_->setObjectiveOffset(0.0);
263 }
264 
267 }
268 
271 }
272 
273 void CLPInterface::CreateDummyVariableForEmptyConstraints() {
274  clp_->setColumnBounds(kDummyVariableIndex, 0.0, 0.0);
275  clp_->setObjectiveCoefficient(kDummyVariableIndex, 0.0);
276  // Workaround for peculiar signature of setColumnName. Note that we do need
277  // std::string here, and not 'string', which aren't the same as of 2013-12
278  // (this will change later).
279  std::string dummy = "dummy"; // We do need to create this temporary variable.
280  clp_->setColumnName(kDummyVariableIndex, dummy);
281 }
282 
283 // Define new variables and add them to existing constraints.
285  // Define new variables
286  int total_num_vars = solver_->variables_.size();
287  if (total_num_vars > last_variable_index_) {
288  if (last_variable_index_ == 0 && last_constraint_index_ == 0) {
289  // Faster extraction when nothing has been extracted yet.
290  clp_->resize(0, total_num_vars + 1);
291  CreateDummyVariableForEmptyConstraints();
292  for (int i = 0; i < total_num_vars; ++i) {
293  MPVariable* const var = solver_->variables_[i];
294  set_variable_as_extracted(i, true);
295  if (!var->name().empty()) {
296  std::string name = var->name();
297  clp_->setColumnName(MPSolverVarIndexToClpVarIndex(i), name);
298  }
299  clp_->setColumnBounds(MPSolverVarIndexToClpVarIndex(i), var->lb(),
300  var->ub());
301  }
302  } else {
303  // TODO(user): This could perhaps be made slightly faster by
304  // iterating through old constraints, constructing by hand the
305  // column-major representation of the addition to them and call
306  // clp_->addColumns. But this is good enough for now.
307  // Create new variables.
308  for (int j = last_variable_index_; j < total_num_vars; ++j) {
309  MPVariable* const var = solver_->variables_[j];
310  DCHECK(!variable_is_extracted(j));
311  set_variable_as_extracted(j, true);
312  // The true objective coefficient will be set later in ExtractObjective.
313  double tmp_obj_coef = 0.0;
314  clp_->addColumn(0, nullptr, nullptr, var->lb(), var->ub(),
315  tmp_obj_coef);
316  if (!var->name().empty()) {
317  std::string name = var->name();
318  clp_->setColumnName(MPSolverVarIndexToClpVarIndex(j), name);
319  }
320  }
321  // Add new variables to existing constraints.
322  for (int i = 0; i < last_constraint_index_; i++) {
323  MPConstraint* const ct = solver_->constraints_[i];
324  const int ct_index = ct->index();
325  for (const auto& entry : ct->coefficients_) {
326  const int mpsolver_var_index = entry.first->index();
327  DCHECK(variable_is_extracted(mpsolver_var_index));
328  if (mpsolver_var_index >= last_variable_index_) {
329  clp_->modifyCoefficient(
330  ct_index, MPSolverVarIndexToClpVarIndex(mpsolver_var_index),
331  entry.second);
332  }
333  }
334  }
335  }
336  }
337 }
338 
339 // Define new constraints on old and new variables.
341  int total_num_rows = solver_->constraints_.size();
342  if (last_constraint_index_ < total_num_rows) {
343  // Find the length of the longest row.
344  int max_row_length = 0;
345  for (int i = last_constraint_index_; i < total_num_rows; ++i) {
346  MPConstraint* const ct = solver_->constraints_[i];
347  DCHECK(!constraint_is_extracted(ct->index()));
348  set_constraint_as_extracted(ct->index(), true);
349  if (ct->coefficients_.size() > max_row_length) {
350  max_row_length = ct->coefficients_.size();
351  }
352  }
353  // Make space for dummy variable.
354  max_row_length = std::max(1, max_row_length);
355  std::unique_ptr<int[]> indices(new int[max_row_length]);
356  std::unique_ptr<double[]> coefs(new double[max_row_length]);
357  CoinBuild build_object;
358  // Add each new constraint.
359  for (int i = last_constraint_index_; i < total_num_rows; ++i) {
360  MPConstraint* const ct = solver_->constraints_[i];
361  DCHECK(constraint_is_extracted(ct->index()));
362  int size = ct->coefficients_.size();
363  if (size == 0) {
364  // Add dummy variable to be able to build the constraint.
365  indices[0] = kDummyVariableIndex;
366  coefs[0] = 1.0;
367  size = 1;
368  }
369  int j = 0;
370  for (const auto& entry : ct->coefficients_) {
371  const int mpsolver_var_index = entry.first->index();
372  DCHECK(variable_is_extracted(mpsolver_var_index));
373  indices[j] = MPSolverVarIndexToClpVarIndex(mpsolver_var_index);
374  coefs[j] = entry.second;
375  j++;
376  }
377  build_object.addRow(size, indices.get(), coefs.get(), ct->lb(), ct->ub());
378  }
379  // Add and name the rows.
380  clp_->addRows(build_object);
381  for (int i = last_constraint_index_; i < total_num_rows; ++i) {
382  MPConstraint* const ct = solver_->constraints_[i];
383  if (!ct->name().empty()) {
384  std::string name = ct->name();
385  clp_->setRowName(ct->index(), name);
386  }
387  }
388  }
389 }
390 
392  // Linear objective: set objective coefficients for all variables
393  // (some might have been modified)
394  for (const auto& entry : solver_->objective_->coefficients_) {
395  clp_->setObjectiveCoefficient(
396  MPSolverVarIndexToClpVarIndex(entry.first->index()), entry.second);
397  }
398 
399  // Constant term. Use -offset instead of +offset because CLP does
400  // not follow conventions.
401  clp_->setObjectiveOffset(-solver_->Objective().offset());
402 }
403 
404 // Extracts model and solve the LP/MIP. Returns the status of the search.
406  try {
407  WallTimer timer;
408  timer.Start();
409 
412  Reset();
413  }
414 
415  // Set log level.
416  CoinMessageHandler message_handler;
417  clp_->passInMessageHandler(&message_handler);
418  if (quiet_) {
419  message_handler.setLogLevel(1, 0);
420  clp_->setLogLevel(0);
421  } else {
422  message_handler.setLogLevel(1, 1);
423  clp_->setLogLevel(1);
424  }
425 
426  // Special case if the model is empty since CLP is not able to
427  // handle this special case by itself.
428  if (solver_->variables_.empty() && solver_->constraints_.empty()) {
432  return result_status_;
433  }
434 
435  ExtractModel();
436  VLOG(1) << absl::StrFormat("Model built in %.3f seconds.", timer.Get());
437 
438  // Time limit.
439  if (solver_->time_limit() != 0) {
440  VLOG(1) << "Setting time limit = " << solver_->time_limit() << " ms.";
441  clp_->setMaximumSeconds(solver_->time_limit_in_secs());
442  } else {
443  clp_->setMaximumSeconds(-1.0);
444  }
445 
446  // Start from a fresh set of default parameters and set them to
447  // specified values.
448  options_ = absl::make_unique<ClpSolve>();
449  SetParameters(param);
450 
451  // Solve
452  timer.Restart();
453  clp_->initialSolve(*options_);
454  VLOG(1) << absl::StrFormat("Solved in %.3f seconds.", timer.Get());
455 
456  // Check the status: optimal, infeasible, etc.
457  int tmp_status = clp_->status();
458  VLOG(1) << "clp result status: " << tmp_status;
459  switch (tmp_status) {
460  case CLP_SIMPLEX_FINISHED:
462  break;
463  case CLP_SIMPLEX_INFEASIBLE:
465  break;
466  case CLP_SIMPLEX_UNBOUNDED:
468  break;
469  case CLP_SIMPLEX_STOPPED:
471  break;
472  default:
474  break;
475  }
476 
479  // Get the results
480  objective_value_ = clp_->objectiveValue();
481  VLOG(1) << "objective=" << objective_value_;
482  const double* const values = clp_->getColSolution();
483  const double* const reduced_costs = clp_->getReducedCost();
484  for (int i = 0; i < solver_->variables_.size(); ++i) {
485  MPVariable* const var = solver_->variables_[i];
486  const int clp_var_index = MPSolverVarIndexToClpVarIndex(var->index());
487  const double val = values[clp_var_index];
488  var->set_solution_value(val);
489  VLOG(3) << var->name() << ": value = " << val;
490  double reduced_cost = reduced_costs[clp_var_index];
491  var->set_reduced_cost(reduced_cost);
492  VLOG(4) << var->name() << ": reduced cost = " << reduced_cost;
493  }
494  const double* const dual_values = clp_->getRowPrice();
495  for (int i = 0; i < solver_->constraints_.size(); ++i) {
496  MPConstraint* const ct = solver_->constraints_[i];
497  const int constraint_index = ct->index();
498  const double dual_value = dual_values[constraint_index];
499  ct->set_dual_value(dual_value);
500  VLOG(4) << "row " << ct->index() << " dual value = " << dual_value;
501  }
502  }
503 
504  ResetParameters();
506  return result_status_;
507  } catch (CoinError &e) {
508  LOG(WARNING) << "Caught exception in Coin LP: " << e.message();
510  return result_status_;
511  }
512 }
513 
514 MPSolver::BasisStatus CLPInterface::TransformCLPBasisStatus(
515  ClpSimplex::Status clp_basis_status) const {
516  switch (clp_basis_status) {
517  case ClpSimplex::isFree:
518  return MPSolver::FREE;
519  case ClpSimplex::basic:
520  return MPSolver::BASIC;
521  case ClpSimplex::atUpperBound:
523  case ClpSimplex::atLowerBound:
525  case ClpSimplex::superBasic:
526  return MPSolver::FREE;
527  case ClpSimplex::isFixed:
528  return MPSolver::FIXED_VALUE;
529  default:
530  LOG(FATAL) << "Unknown CLP basis status";
531  return MPSolver::FREE;
532  }
533 }
534 
535 // ------ Query statistics on the solution and the solve ------
536 
539  return clp_->getIterationCount();
540 }
541 
543  LOG(DFATAL) << "Number of nodes only available for discrete problems";
544  return kUnknownNumberOfNodes;
545 }
546 
548  LOG(DFATAL) << "Best objective bound only available for discrete problems";
550 }
551 
552 MPSolver::BasisStatus CLPInterface::row_status(int constraint_index) const {
553  DCHECK_LE(0, constraint_index);
554  DCHECK_GT(last_constraint_index_, constraint_index);
555  const ClpSimplex::Status clp_basis_status =
556  clp_->getRowStatus(constraint_index);
557  return TransformCLPBasisStatus(clp_basis_status);
558 }
559 
561  DCHECK_LE(0, variable_index);
562  DCHECK_GT(last_variable_index_, variable_index);
563  const ClpSimplex::Status clp_basis_status =
564  clp_->getColumnStatus(MPSolverVarIndexToClpVarIndex(variable_index));
565  return TransformCLPBasisStatus(clp_basis_status);
566 }
567 
568 // ------ Parameters ------
569 
570 void CLPInterface::SetParameters(const MPSolverParameters& param) {
571  SetCommonParameters(param);
572 }
573 
574 void CLPInterface::ResetParameters() {
575  clp_->setPrimalTolerance(MPSolverParameters::kDefaultPrimalTolerance);
576  clp_->setDualTolerance(MPSolverParameters::kDefaultDualTolerance);
577 }
578 
579 void CLPInterface::SetRelativeMipGap(double value) {
580  LOG(WARNING) << "The relative MIP gap is only available "
581  << "for discrete problems.";
582 }
583 
584 void CLPInterface::SetPrimalTolerance(double value) {
585  clp_->setPrimalTolerance(value);
586 }
587 
588 void CLPInterface::SetDualTolerance(double value) {
589  clp_->setDualTolerance(value);
590 }
591 
592 void CLPInterface::SetPresolveMode(int value) {
593  switch (value) {
595  options_->setPresolveType(ClpSolve::presolveOff);
596  break;
597  }
599  options_->setPresolveType(ClpSolve::presolveOn);
600  break;
601  }
602  default: {
604  }
605  }
606 }
607 
608 void CLPInterface::SetScalingMode(int value) {
610 }
611 
612 void CLPInterface::SetLpAlgorithm(int value) {
613  switch (value) {
615  options_->setSolveType(ClpSolve::useDual);
616  break;
617  }
619  options_->setSolveType(ClpSolve::usePrimal);
620  break;
621  }
623  options_->setSolveType(ClpSolve::useBarrier);
624  break;
625  }
626  default: {
628  value);
629  }
630  }
631 }
632 
634  return new CLPInterface(solver);
635 }
636 
637 } // namespace operations_research
638 #endif // #if defined(USE_CBC) || defined(USE_CLP)
operations_research::MPSolverInterface::variable_is_extracted
bool variable_is_extracted(int var_index) const
Definition: linear_solver.h:1658
var
IntVar * var
Definition: expr_array.cc:1858
operations_research::MPSolverParameters::GetIntegerParam
int GetIntegerParam(MPSolverParameters::IntegerParam param) const
Returns the value of an integer parameter.
Definition: linear_solver.cc:1973
operations_research::MPSolverParameters::LP_ALGORITHM
@ LP_ALGORITHM
Algorithm to solve linear programs.
Definition: linear_solver.h:1381
operations_research::CLPInterface::SetConstraintBounds
void SetConstraintBounds(int row_index, double lb, double ub) override
Definition: clp_interface.cc:183
integral_types.h
operations_research::MPVariable
The class for variables of a Mathematical Programming (MP) model.
Definition: linear_solver.h:1050
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::MPSolverInterface::MUST_RELOAD
@ MUST_RELOAD
Definition: linear_solver.h:1519
operations_research::MPSolverParameters::PRESOLVE_OFF
@ PRESOLVE_OFF
Presolve is off.
Definition: linear_solver.h:1391
operations_research::MPSolverInterface::result_status_
MPSolver::ResultStatus result_status_
Definition: linear_solver.h:1723
max
int64 max
Definition: alldiff_cst.cc:139
operations_research::MPVariable::index
int index() const
Returns the index of the variable in the MPSolver::variables_.
Definition: linear_solver.h:1071
operations_research::CLPInterface
Definition: clp_interface.cc:42
operations_research::MPSolver::FIXED_VALUE
@ FIXED_VALUE
Definition: linear_solver.h:644
operations_research::MPConstraint
The class for constraints of a Mathematical Programming (MP) model.
Definition: linear_solver.h:1175
operations_research::MPSolver::FEASIBLE
@ FEASIBLE
feasible, or stopped by limit.
Definition: linear_solver.h:429
operations_research::MPSolverInterface::objective_value_
double objective_value_
Definition: linear_solver.h:1733
logging.h
operations_research::CLPInterface::Solve
MPSolver::ResultStatus Solve(const MPSolverParameters &param) override
Definition: clp_interface.cc:405
operations_research::MPSolver::time_limit
int64 time_limit() const
Definition: linear_solver.h:777
operations_research::MPObjective::offset
double offset() const
Gets the constant term in the objective.
Definition: linear_solver.h:959
operations_research::CLPInterface::IsLP
bool IsLP() const override
Definition: clp_interface.cc:99
operations_research::MPSolver::AT_LOWER_BOUND
@ AT_LOWER_BOUND
Definition: linear_solver.h:642
operations_research::CLPInterface::best_objective_bound
double best_objective_bound() const override
Definition: clp_interface.cc:547
value
int64 value
Definition: demon_profiler.cc:43
operations_research::MPSolverParameters::DUAL
@ DUAL
Dual simplex.
Definition: linear_solver.h:1399
operations_research::MPSolverInterface::set_variable_as_extracted
void set_variable_as_extracted(int var_index, bool extracted)
Definition: linear_solver.h:1661
operations_research::MPSolverInterface::MODEL_SYNCHRONIZED
@ MODEL_SYNCHRONIZED
Definition: linear_solver.h:1523
operations_research::CLPInterface::AddVariable
void AddVariable(MPVariable *const var) override
Definition: clp_interface.cc:269
operations_research::MPSolverParameters::kDefaultDualTolerance
static const double kDefaultDualTolerance
Definition: linear_solver.h:1442
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::MPSolverParameters::SCALING
@ SCALING
Advanced usage: enable or disable matrix scaling.
Definition: linear_solver.h:1385
operations_research::MPSolverInterface::kDummyVariableIndex
static const int kDummyVariableIndex
Definition: linear_solver.h:1740
operations_research::CLPInterface::AddRowConstraint
void AddRowConstraint(MPConstraint *const ct) override
Definition: clp_interface.cc:265
operations_research::CLPInterface::CLPInterface
CLPInterface(MPSolver *const solver)
Definition: clp_interface.cc:141
operations_research::MPSolverInterface::last_variable_index_
int last_variable_index_
Definition: linear_solver.h:1730
int64
int64_t int64
Definition: integral_types.h:34
operations_research::MPSolverParameters
This class stores parameter settings for LP and MIP solvers.
Definition: linear_solver.h:1358
operations_research::MPSolverInterface::CheckSolutionIsSynchronized
bool CheckSolutionIsSynchronized() const
Definition: linear_solver.cc:1648
index
int index
Definition: pack.cc:508
operations_research::MPSolverParameters::kDefaultPrimalTolerance
static const double kDefaultPrimalTolerance
Definition: linear_solver.h:1441
operations_research::CLPInterface::SetObjectiveCoefficient
void SetObjectiveCoefficient(const MPVariable *const variable, double coefficient) override
Definition: clp_interface.cc:228
operations_research::MPSolverParameters::INCREMENTALITY
@ INCREMENTALITY
Advanced usage: incrementality from one solve to the next.
Definition: linear_solver.h:1383
operations_research::MPSolverInterface::SetIntegerParamToUnsupportedValue
virtual void SetIntegerParamToUnsupportedValue(MPSolverParameters::IntegerParam param, int value)
Definition: linear_solver.cc:1748
operations_research::MPConstraint::index
int index() const
Returns the index of the constraint in the MPSolver::constraints_.
Definition: linear_solver.h:1243
WallTimer::Get
double Get() const
Definition: timer.h:45
operations_research::MPSolverInterface::SetCommonParameters
void SetCommonParameters(const MPSolverParameters &param)
Definition: linear_solver.cc:1707
operations_research::MPSolverInterface::ExtractModel
void ExtractModel()
Definition: linear_solver.cc:1612
WallTimer::Restart
void Restart()
Definition: timer.h:35
operations_research::MPSolverParameters::PRIMAL
@ PRIMAL
Primal simplex.
Definition: linear_solver.h:1401
timer.h
operations_research::CLPInterface::SolverVersion
std::string SolverVersion() const override
Definition: clp_interface.cc:106
operations_research::MPSolverInterface::set_constraint_as_extracted
void set_constraint_as_extracted(int ct_index, bool extracted)
Definition: linear_solver.h:1667
operations_research::MPSolver::ABNORMAL
@ ABNORMAL
abnormal, i.e., error of some kind.
Definition: linear_solver.h:435
operations_research::CLPInterface::SetVariableInteger
void SetVariableInteger(int var_index, bool integer) override
Definition: clp_interface.cc:181
operations_research::MPSolverInterface::ResetExtractionInformation
void ResetExtractionInformation()
Definition: linear_solver.cc:1640
operations_research::MPSolverInterface::kUnknownNumberOfNodes
static constexpr int64 kUnknownNumberOfNodes
Definition: linear_solver.h:1534
operations_research::MPSolverInterface::quiet_
bool quiet_
Definition: linear_solver.h:1736
operations_research::MPSolverParameters::INCREMENTALITY_OFF
@ INCREMENTALITY_OFF
Start solve from scratch.
Definition: linear_solver.h:1409
operations_research::CLPInterface::iterations
int64 iterations() const override
Definition: clp_interface.cc:537
operations_research::MPSolverInterface::maximize_
bool maximize_
Definition: linear_solver.h:1725
operations_research::BuildCLPInterface
MPSolverInterface * BuildCLPInterface(MPSolver *const solver)
Definition: clp_interface.cc:633
WallTimer
Definition: timer.h:23
ct
const Constraint * ct
Definition: demon_profiler.cc:42
operations_research::CLPInterface::underlying_solver
void * underlying_solver() override
Definition: clp_interface.cc:108
operations_research::CLPInterface::~CLPInterface
~CLPInterface() override
Definition: clp_interface.cc:147
operations_research::CLPInterface::SetCoefficient
void SetCoefficient(MPConstraint *const constraint, const MPVariable *const variable, double new_value, double old_value) override
Definition: clp_interface.cc:194
operations_research::CLPInterface::ExtractObjective
void ExtractObjective() override
Definition: clp_interface.cc:391
operations_research::MPSolverInterface
Definition: linear_solver.h:1514
operations_research::CLPInterface::ClearConstraint
void ClearConstraint(MPConstraint *const constraint) override
Definition: clp_interface.cc:215
operations_research::MPSolver::AT_UPPER_BOUND
@ AT_UPPER_BOUND
Definition: linear_solver.h:643
operations_research::MPSolverParameters::PRESOLVE
@ PRESOLVE
Advanced usage: presolve mode.
Definition: linear_solver.h:1379
operations_research::CLPInterface::ExtractNewVariables
void ExtractNewVariables() override
Definition: clp_interface.cc:284
operations_research::CLPInterface::row_status
MPSolver::BasisStatus row_status(int constraint_index) const override
Definition: clp_interface.cc:552
operations_research::MPSolver::Objective
const MPObjective & Objective() const
Returns the objective object.
Definition: linear_solver.h:414
operations_research::MPSolver::OPTIMAL
@ OPTIMAL
optimal.
Definition: linear_solver.h:427
operations_research::MPSolver::ResultStatus
ResultStatus
The status of solving the problem.
Definition: linear_solver.h:425
operations_research::CLPInterface::ClearObjective
void ClearObjective() override
Definition: clp_interface.cc:248
WallTimer::Start
void Start()
Definition: timer.h:31
coefficient
int64 coefficient
Definition: routing_search.cc:973
operations_research::CLPInterface::nodes
int64 nodes() const override
Definition: clp_interface.cc:542
operations_research::MPSolver::FREE
@ FREE
Definition: linear_solver.h:641
operations_research::MPSolverInterface::SetUnsupportedIntegerParam
virtual void SetUnsupportedIntegerParam(MPSolverParameters::IntegerParam param)
Definition: linear_solver.cc:1739
operations_research::MPSolverParameters::BARRIER
@ BARRIER
Barrier algorithm.
Definition: linear_solver.h:1403
operations_research::CLPInterface::IsContinuous
bool IsContinuous() const override
Definition: clp_interface.cc:98
hash.h
linear_solver.h
operations_research::CLPInterface::SetObjectiveOffset
void SetObjectiveOffset(double offset) override
Definition: clp_interface.cc:240
operations_research::MPSolver::time_limit_in_secs
double time_limit_in_secs() const
Definition: linear_solver.h:787
operations_research::MPSolverInterface::solver_
MPSolver *const solver_
Definition: linear_solver.h:1718
operations_research::CLPInterface::column_status
MPSolver::BasisStatus column_status(int variable_index) const override
Definition: clp_interface.cc:560
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::MPSolverInterface::SOLUTION_SYNCHRONIZED
@ SOLUTION_SYNCHRONIZED
Definition: linear_solver.h:1526
operations_research::MPSolverInterface::constraint_is_extracted
bool constraint_is_extracted(int ct_index) const
Definition: linear_solver.h:1664
operations_research::CLPInterface::IsMIP
bool IsMIP() const override
Definition: clp_interface.cc:100
operations_research::MPSolverInterface::kUnknownNumberOfIterations
static constexpr int64 kUnknownNumberOfIterations
Definition: linear_solver.h:1531
operations_research::MPSolverInterface::last_constraint_index_
int last_constraint_index_
Definition: linear_solver.h:1728
operations_research::MPSolverParameters::PRESOLVE_ON
@ PRESOLVE_ON
Presolve is on.
Definition: linear_solver.h:1393
operations_research::CLPInterface::SetOptimizationDirection
void SetOptimizationDirection(bool maximize) override
Definition: clp_interface.cc:164
operations_research::MPSolverInterface::trivial_worst_objective_bound
double trivial_worst_objective_bound() const
Definition: linear_solver.cc:1682
commandlineflags.h
name
const std::string name
Definition: default_search.cc:807
operations_research::MPSolver::INFEASIBLE
@ INFEASIBLE
proven infeasible.
Definition: linear_solver.h:431
operations_research::CLPInterface::ExtractNewConstraints
void ExtractNewConstraints() override
Definition: clp_interface.cc:340
operations_research::MPSolverInterface::sync_status_
SynchronizationStatus sync_status_
Definition: linear_solver.h:1720
operations_research::CLPInterface::SetVariableBounds
void SetVariableBounds(int var_index, double lb, double ub) override
Definition: clp_interface.cc:169
operations_research::MPSolver::BASIC
@ BASIC
Definition: linear_solver.h:645
operations_research::MPSolverInterface::InvalidateSolutionSynchronization
void InvalidateSolutionSynchronization()
Definition: linear_solver.cc:1692
operations_research::CLPInterface::Reset
void Reset() override
Definition: clp_interface.cc:149
operations_research::MPSolver::UNBOUNDED
@ UNBOUNDED
proven unbounded.
Definition: linear_solver.h:433