Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
Public Member Functions | |
SCIPInterface (MPSolver *solver) | |
~SCIPInterface () override | |
void | SetOptimizationDirection (bool maximize) override |
Not cached. | |
MPSolver::ResultStatus | Solve (const MPSolverParameters ¶m) override |
bool | SupportsDirectlySolveProto (std::atomic< bool > *interrupt) const override |
MPSolutionResponse | DirectlySolveProto (LazyMutableCopy< MPModelRequest > request, std::atomic< bool > *interrupt) override |
void | Reset () override |
double | infinity () override |
void | SetVariableBounds (int var_index, double lb, double ub) override |
Modifies bounds of an extracted variable. | |
void | SetVariableInteger (int var_index, bool integer) override |
Modifies integrality of an extracted variable. | |
void | SetConstraintBounds (int row_index, double lb, double ub) override |
Modify bounds of an extracted variable. | |
void | AddRowConstraint (MPConstraint *ct) override |
Adds a linear constraint. | |
bool | AddIndicatorConstraint (MPConstraint *ct) override |
void | AddVariable (MPVariable *var) override |
Add a variable. | |
void | SetCoefficient (MPConstraint *constraint, const MPVariable *variable, double new_value, double old_value) override |
Changes a coefficient in a constraint. | |
void | ClearConstraint (MPConstraint *constraint) override |
Not cached. | |
void | SetObjectiveCoefficient (const MPVariable *variable, double coefficient) override |
Cached. | |
void | SetObjectiveOffset (double value) override |
Cached. | |
void | ClearObjective () override |
Clear objective of all its terms. | |
void | BranchingPriorityChangedForVariable (int var_index) override |
int64_t | iterations () const override |
int64_t | nodes () const override |
MPSolver::BasisStatus | row_status (int constraint_index) const override |
Returns the basis status of a row. | |
MPSolver::BasisStatus | column_status (int variable_index) const override |
Returns the basis status of a constraint. | |
bool | IsContinuous () const override |
bool | IsLP () const override |
Returns true if the problem is continuous and linear. | |
bool | IsMIP () const override |
Returns true if the problem is discrete and linear. | |
void | ExtractNewVariables () override |
Extracts the variables that have not been extracted yet. | |
void | ExtractNewConstraints () override |
Extracts the constraints that have not been extracted yet. | |
void | ExtractObjective () override |
Extracts the objective. | |
std::string | SolverVersion () const override |
Returns a string describing the underlying solver and its version. | |
bool | InterruptSolve () override |
void * | underlying_solver () override |
Returns the underlying solver. | |
bool | NextSolution () override |
void | SetCallback (MPCallback *mp_callback) override |
MPCallback API. | |
bool | SupportsCallbacks () const override |
Public Member Functions inherited from operations_research::MPSolverInterface | |
MPSolverInterface (MPSolver *solver) | |
virtual | ~MPSolverInterface () |
virtual void | Write (const std::string &filename) |
double | best_objective_bound () const |
double | objective_value () const |
Returns the objective value of the best solution found so far. | |
bool | CheckSolutionIsSynchronized () const |
virtual bool | CheckSolutionExists () const |
bool | CheckSolutionIsSynchronizedAndExists () const |
Handy shortcut to do both checks above (it is often used). | |
int | last_variable_index () const |
Returns the index of the last variable extracted. | |
bool | variable_is_extracted (int var_index) const |
void | set_variable_as_extracted (int var_index, bool extracted) |
bool | constraint_is_extracted (int ct_index) const |
void | set_constraint_as_extracted (int ct_index, bool extracted) |
bool | quiet () const |
Returns the boolean indicating the verbosity of the solver output. | |
void | set_quiet (bool quiet_value) |
Sets the boolean indicating the verbosity of the solver output. | |
MPSolver::ResultStatus | result_status () const |
Returns the result status of the last solve. | |
virtual double | ComputeExactConditionNumber () const |
virtual void | SetStartingLpBasis (const std::vector< MPSolver::BasisStatus > &, const std::vector< MPSolver::BasisStatus > &) |
See MPSolver::SetStartingLpBasis(). | |
Additional Inherited Members | |
Public Types inherited from operations_research::MPSolverInterface | |
enum | SynchronizationStatus { MUST_RELOAD , MODEL_SYNCHRONIZED , SOLUTION_SYNCHRONIZED } |
Static Public Attributes inherited from operations_research::MPSolverInterface | |
static constexpr int64_t | kUnknownNumberOfIterations = -1 |
static constexpr int64_t | kUnknownNumberOfNodes = -1 |
Protected Member Functions inherited from operations_research::MPSolverInterface | |
void | ExtractModel () |
Extracts model stored in MPSolver. | |
void | ResetExtractionInformation () |
Resets the extraction information. | |
void | InvalidateSolutionSynchronization () |
void | SetCommonParameters (const MPSolverParameters ¶m) |
Sets parameters common to LP and MIP in the underlying solver. | |
void | SetMIPParameters (const MPSolverParameters ¶m) |
Sets MIP specific parameters in the underlying solver. | |
void | SetUnsupportedDoubleParam (MPSolverParameters::DoubleParam param) |
Sets an unsupported double parameter. | |
void | SetDoubleParamToUnsupportedValue (MPSolverParameters::DoubleParam param, double value) |
Sets a supported double parameter to an unsupported value. | |
Protected Attributes inherited from operations_research::MPSolverInterface | |
MPSolver *const | solver_ |
SynchronizationStatus | sync_status_ |
Indicates whether the model and the solution are synchronized. | |
MPSolver::ResultStatus | result_status_ |
bool | maximize_ |
Optimization direction. | |
int | last_constraint_index_ |
Index in MPSolver::variables_ of last constraint extracted. | |
int | last_variable_index_ |
Index in MPSolver::constraints_ of last variable extracted. | |
double | objective_value_ |
The value of the objective function. | |
double | best_objective_bound_ |
The value of the best objective bound. Used only for MIP solvers. | |
bool | quiet_ |
Boolean indicator for the verbosity of the solver output. | |
Static Protected Attributes inherited from operations_research::MPSolverInterface | |
static const int | kDummyVariableIndex = 0 |
-------— MPSolverInterface -------— | |
Definition at line 67 of file scip_interface.cc.
|
explicit |
Definition at line 258 of file scip_interface.cc.
|
override |
Definition at line 263 of file scip_interface.cc.
|
overridevirtual |
Adds an indicator constraint. Returns true if the feature is supported by the underlying solver.
Reimplemented from operations_research::MPSolverInterface.
Definition at line 499 of file scip_interface.cc.
|
overridevirtual |
Adds a linear constraint.
Implements operations_research::MPSolverInterface.
Definition at line 495 of file scip_interface.cc.
|
overridevirtual |
Add a variable.
Implements operations_research::MPSolverInterface.
Definition at line 504 of file scip_interface.cc.
|
overridevirtual |
As of 2019-05, SCIP does not support setting branching priority for variables in models that have already been solved. Therefore, we force reset the model when setting the priority on an already extracted variable.
Reimplemented from operations_research::MPSolverInterface.
Definition at line 483 of file scip_interface.cc.
|
overridevirtual |
Not cached.
Constraint may not have been extracted yet.
Set coefficient to zero by subtracting the old coefficient value.
Implements operations_research::MPSolverInterface.
Definition at line 429 of file scip_interface.cc.
|
overridevirtual |
Clear objective of all its terms.
Clear linear terms
Variable may have not been extracted yet.
Implements operations_research::MPSolverInterface.
Definition at line 459 of file scip_interface.cc.
|
inlineoverridevirtual |
Returns the basis status of a constraint.
Implements operations_research::MPSolverInterface.
Definition at line 105 of file scip_interface.cc.
|
overridevirtual |
Reimplemented from operations_research::MPSolverInterface.
Definition at line 884 of file scip_interface.cc.
|
overridevirtual |
Extracts the constraints that have not been extracted yet.
Find the length of the longest row.
Add each new constraint.
See http://scip.zib.de/doc/html/cons__linear_8h.php#aa7aed137a4130b35b168812414413481 for an explanation of the parameters.
Implements operations_research::MPSolverInterface.
Definition at line 551 of file scip_interface.cc.
|
overridevirtual |
Extracts the variables that have not been extracted yet.
Define new variables
The true objective coefficient will be set later in ExtractObjective.
Add new variables to existing constraints.
The variable is new, so we know the previous coefficient value was 0 and we can directly add the coefficient.
Implements operations_research::MPSolverInterface.
Definition at line 506 of file scip_interface.cc.
|
overridevirtual |
Extracts the objective.
Linear objective: set objective coefficients for all variables (some might have been modified).
Constant term: change objective offset.
Implements operations_research::MPSolverInterface.
Definition at line 651 of file scip_interface.cc.
|
overridevirtual |
Reimplemented from operations_research::MPSolverInterface.
Definition at line 317 of file scip_interface.cc.
|
inlineoverridevirtual |
Reimplemented from operations_research::MPSolverInterface.
Definition at line 124 of file scip_interface.cc.
|
inlineoverridevirtual |
--— Misc --— Queries problem type. For simplicity, the distinction between continuous and discrete is based on the declaration of the user when the solver is created (example: GLPK_LINEAR_PROGRAMMING vs. GLPK_MIXED_INTEGER_PROGRAMMING), not on the actual content of the model. Returns true if the problem is continuous.
Implements operations_research::MPSolverInterface.
Definition at line 110 of file scip_interface.cc.
|
inlineoverridevirtual |
Returns true if the problem is continuous and linear.
Implements operations_research::MPSolverInterface.
Definition at line 111 of file scip_interface.cc.
|
inlineoverridevirtual |
Returns true if the problem is discrete and linear.
Implements operations_research::MPSolverInterface.
Definition at line 112 of file scip_interface.cc.
|
overridevirtual |
---— Query statistics on the solution and the solve ---— Returns the number of simplex iterations. The problem must be discrete, otherwise it crashes, or returns kUnknownNumberOfIterations in NDEBUG mode.
NOTE(user): As of 2018-12 it doesn't run in the stubby server, and is a specialized call, so it's ok to crash if the status is broken.
Implements operations_research::MPSolverInterface.
Definition at line 907 of file scip_interface.cc.
|
overridevirtual |
MULTIPLE SOLUTIONS SUPPORT The default behavior of scip is to store the top incidentally generated integer solutions in the solution pool. The default maximum size is 100. This can be adjusted by setting the param limits/maxsol. There is no way to ensure that the pool will actually be full.
You can also ask SCIP to enumerate all feasible solutions. Combined with an equality or inequality constraint on the objective (after solving once to find the optimal solution), you can use this to find all high quality solutions. See https://scip.zib.de/doc/html/COUNTER.php. This behavior is not supported directly through MPSolver, but in theory can be controlled entirely through scip parameters.
Make sure we have successfully solved the problem and not modified it.
Reimplemented from operations_research::MPSolverInterface.
Definition at line 893 of file scip_interface.cc.
|
overridevirtual |
Returns the number of branch-and-bound nodes. The problem must be discrete, otherwise it crashes, or returns kUnknownNumberOfNodes in NDEBUG mode.
NOTE(user): Same story as iterations(): it's OK to crash here.
This is the total number of nodes used in the solve, potentially across multiple branch-and-bound trees. Use limits/totalnodes (rather than limits/nodes) to control this value.
Implements operations_research::MPSolverInterface.
Definition at line 914 of file scip_interface.cc.
|
overridevirtual |
--— Model modifications and extraction --— Resets extracted model.
We hold calls to SCIPinterruptSolve() until the new scip_ is fully built.
Remove existing one but keep it alive to copy parameters from it.
Install the new one.
Copy all existing parameters from the previous SCIP to the new one. This ensures that if a user calls multiple times SetSolverSpecificParametersAsString() and then Reset() is called, we still take into account all parameters. Note though that at the end of Solve(), parameters are reset so after Solve() has been called, only the last set parameters are kept.
Implements operations_research::MPSolverInterface.
Definition at line 265 of file scip_interface.cc.
|
inlineoverridevirtual |
Returns the basis status of a row.
Implements operations_research::MPSolverInterface.
Definition at line 101 of file scip_interface.cc.
|
overridevirtual |
MPCallback API.
CALLBACK SUPPORT:
Reimplemented from operations_research::MPSolverInterface.
Definition at line 1148 of file scip_interface.cc.
|
overridevirtual |
Changes a coefficient in a constraint.
The modification of the coefficient for an extracted row and variable is not cached.
SCIP does not allow to set a coefficient directly, so we add the difference between the new and the old value instead.
The modification of an unextracted row or variable is cached and handled in ExtractModel.
Implements operations_research::MPSolverInterface.
Definition at line 404 of file scip_interface.cc.
|
overridevirtual |
Modify bounds of an extracted variable.
Not cached if the row has been extracted.
Implements operations_research::MPSolverInterface.
Definition at line 388 of file scip_interface.cc.
|
overridevirtual |
Cached.
Implements operations_research::MPSolverInterface.
Definition at line 448 of file scip_interface.cc.
|
overridevirtual |
Cached.
Implements operations_research::MPSolverInterface.
Definition at line 454 of file scip_interface.cc.
|
overridevirtual |
Not cached.
Implements operations_research::MPSolverInterface.
Definition at line 343 of file scip_interface.cc.
|
overridevirtual |
Modifies bounds of an extracted variable.
Not cached if the variable has been extracted.
Implements operations_research::MPSolverInterface.
Definition at line 351 of file scip_interface.cc.
|
overridevirtual |
Modifies integrality of an extracted variable.
Not cached if the variable has been extracted.
Implements operations_research::MPSolverInterface.
Definition at line 367 of file scip_interface.cc.
|
overridevirtual |
--— Solve --— Solves problem with specified parameter values. Returns true if the solution is optimal.
"status_" may encode a variety of failure scenarios, many of which would correspond to another MPResultStatus than ABNORMAL, but since SCIP is a moving target, we use the most likely error code here (abnormalities, often numeric), and rely on the user enabling output to see more details.
Set log level.
Special case if the model is empty since SCIP expects a non-empty model.
When the value of callback_
is changed, callback_reset_
is set and code above you call Reset() that should have cleared scip_constraint_handler_
. Here we assert that if this has not happened then callback_
value has not changed.
Time limit.
We first set our internal MPSolverParameters from param and then set any user specified internal solver, ie. SCIP, parameters via solver_specific_parameter_string_. Default MPSolverParameters can override custom parameters (for example for presolving) and therefore we apply MPSolverParameters first.
Use the solution hint if any.
We start by creating an empty partial solution.
We start by creating the all-zero solution.
Fill the other variables from the given solution hint.
Solve.
Get the results.
If optimal or feasible solution is found.
Check the status: optimal, infeasible, etc.
To be consistent with the other solvers.
Implements operations_research::MPSolverInterface.
Definition at line 684 of file scip_interface.cc.
|
inlineoverridevirtual |
Returns a string describing the underlying solver and its version.
Implements operations_research::MPSolverInterface.
Definition at line 118 of file scip_interface.cc.
|
inlineoverridevirtual |
Reimplemented from operations_research::MPSolverInterface.
Definition at line 160 of file scip_interface.cc.
|
overridevirtual |
DirectlySolveProto() shall only be used if SupportsDirectlySolveProto() is true.
DirectlySolveProto() solves a MPModelRequest, bypassing the MPSolver data structures entirely. Like MPSolver::SolveWithProto(), optionally takes in an 'interrupt' boolean.
ScipSolveProto doesn't solve concurrently.
Interruption via atomic<bool> is not directly supported by SCIP.
Reimplemented from operations_research::MPSolverInterface.
Definition at line 873 of file scip_interface.cc.
|
inlineoverridevirtual |
Returns the underlying solver.
Implements operations_research::MPSolverInterface.
Definition at line 134 of file scip_interface.cc.