Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
Public Member Functions | |
KnapsackInterface (MPSolver *solver) | |
~KnapsackInterface () override | |
MPSolver::ResultStatus | Solve (const MPSolverParameters ¶m) override |
--— Solve --— | |
void | Reset () override |
--— Model modifications and extraction --— | |
void | SetOptimizationDirection (bool maximize) override |
Sets the optimization direction (min/max). | |
void | SetVariableBounds (int index, double lb, double ub) override |
Modifies bounds of an extracted variable. | |
void | SetVariableInteger (int index, bool integer) override |
Modifies integrality of an extracted variable. | |
void | SetConstraintBounds (int index, double lb, double ub) override |
Modify bounds of an extracted variable. | |
void | AddRowConstraint (MPConstraint *ct) override |
Adds a linear constraint. | |
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 |
Clears a constraint from all its terms. | |
void | SetObjectiveCoefficient (const MPVariable *variable, double coefficient) override |
Changes a coefficient in the linear objective. | |
void | SetObjectiveOffset (double value) override |
Changes the constant term in the linear objective. | |
void | ClearObjective () override |
Clears the objective from all its terms. | |
int64_t | iterations () const override |
---— Query statistics on the solution and the solve ---— | |
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 |
--— Misc --— | |
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. | |
std::string | SolverVersion () const override |
Returns a string describing the underlying solver and its version. | |
void * | underlying_solver () override |
Returns the underlying solver. | |
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. | |
void | SetParameters (const MPSolverParameters ¶m) override |
Sets all parameters in the underlying solver. | |
void | SetRelativeMipGap (double value) override |
Sets each parameter in the underlying solver. | |
void | SetPrimalTolerance (double value) override |
void | SetDualTolerance (double value) override |
void | SetPresolveMode (int value) override |
void | SetScalingMode (int value) override |
Sets the scaling mode. | |
void | SetLpAlgorithm (int value) override |
Public Member Functions inherited from operations_research::MPSolverInterface | |
MPSolverInterface (MPSolver *solver) | |
virtual | ~MPSolverInterface () |
virtual bool | SupportsDirectlySolveProto (std::atomic< bool > *) const |
virtual MPSolutionResponse | DirectlySolveProto (LazyMutableCopy< MPModelRequest >, std::atomic< bool > *) |
virtual void | Write (const std::string &filename) |
virtual bool | AddIndicatorConstraint (MPConstraint *const) |
virtual void | BranchingPriorityChangedForVariable (int) |
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(). | |
virtual double | infinity () |
virtual bool | InterruptSolve () |
virtual bool | NextSolution () |
See MPSolver::NextSolution() for contract. | |
virtual void | SetCallback (MPCallback *) |
See MPSolver::SetCallback() for details. | |
virtual bool | SupportsCallbacks () const |
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. | |
virtual void | SetUnsupportedIntegerParam (MPSolverParameters::IntegerParam param) |
Sets an unsupported integer parameter. | |
void | SetDoubleParamToUnsupportedValue (MPSolverParameters::DoubleParam param, double value) |
Sets a supported double parameter to an unsupported value. | |
virtual void | SetIntegerParamToUnsupportedValue (MPSolverParameters::IntegerParam param, int value) |
Sets a supported integer parameter to an unsupported value. | |
virtual absl::Status | SetNumThreads (int num_threads) |
Sets the number of threads to be used by the solver. | |
virtual bool | SetSolverSpecificParametersAsString (const std::string ¶meters) |
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 34 of file knapsack_interface.cc.
|
explicit |
Definition at line 97 of file knapsack_interface.cc.
|
override |
Definition at line 100 of file knapsack_interface.cc.
|
overridevirtual |
Adds a linear constraint.
Implements operations_research::MPSolverInterface.
Definition at line 164 of file knapsack_interface.cc.
|
overridevirtual |
Add a variable.
Implements operations_research::MPSolverInterface.
Definition at line 168 of file knapsack_interface.cc.
|
overridevirtual |
Clears a constraint from all its terms.
Implements operations_research::MPSolverInterface.
Definition at line 178 of file knapsack_interface.cc.
|
overridevirtual |
Clears the objective from all its terms.
Implements operations_research::MPSolverInterface.
Definition at line 191 of file knapsack_interface.cc.
|
overridevirtual |
Returns the basis status of a constraint.
Implements operations_research::MPSolverInterface.
Definition at line 203 of file knapsack_interface.cc.
|
overridevirtual |
Extracts the constraints that have not been extracted yet.
Removing the contribution of variables fixed to 1 from the constraint upper bound. All fixed variables have a zero coefficient.
Adding upper bound to the coefficients to scale.
Implements operations_research::MPSolverInterface.
Definition at line 228 of file knapsack_interface.cc.
|
overridevirtual |
Extracts the variables that have not been extracted yet.
Implements operations_research::MPSolverInterface.
Definition at line 221 of file knapsack_interface.cc.
|
overridevirtual |
Extracts the objective.
Whether fixed to 0 or 1, fixed variables are removed from the profit function, which for the current implementation means their coefficient is set to 0.
Implements operations_research::MPSolverInterface.
Definition at line 272 of file knapsack_interface.cc.
|
overridevirtual |
--— Misc --—
Implements operations_research::MPSolverInterface.
Definition at line 209 of file knapsack_interface.cc.
|
overridevirtual |
Returns true if the problem is continuous and linear.
Implements operations_research::MPSolverInterface.
Definition at line 211 of file knapsack_interface.cc.
|
overridevirtual |
Returns true if the problem is discrete and linear.
Implements operations_research::MPSolverInterface.
Definition at line 213 of file knapsack_interface.cc.
|
overridevirtual |
---— Query statistics on the solution and the solve ---—
Implements operations_research::MPSolverInterface.
Definition at line 193 of file knapsack_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.
Implements operations_research::MPSolverInterface.
Definition at line 195 of file knapsack_interface.cc.
|
overridevirtual |
--— Model modifications and extraction --—
Implements operations_research::MPSolverInterface.
Definition at line 140 of file knapsack_interface.cc.
|
overridevirtual |
Returns the basis status of a row.
Implements operations_research::MPSolverInterface.
Definition at line 197 of file knapsack_interface.cc.
|
overridevirtual |
Changes a coefficient in a constraint.
Implements operations_research::MPSolverInterface.
Definition at line 172 of file knapsack_interface.cc.
|
overridevirtual |
Modify bounds of an extracted variable.
Implements operations_research::MPSolverInterface.
Definition at line 160 of file knapsack_interface.cc.
|
overridevirtual |
Implements operations_research::MPSolverInterface.
Definition at line 304 of file knapsack_interface.cc.
|
overridevirtual |
Implements operations_research::MPSolverInterface.
Definition at line 310 of file knapsack_interface.cc.
|
overridevirtual |
Changes a coefficient in the linear objective.
Implements operations_research::MPSolverInterface.
Definition at line 182 of file knapsack_interface.cc.
|
overridevirtual |
Changes the constant term in the linear objective.
Implements operations_research::MPSolverInterface.
Definition at line 187 of file knapsack_interface.cc.
|
overridevirtual |
Sets the optimization direction (min/max).
Implements operations_research::MPSolverInterface.
Definition at line 148 of file knapsack_interface.cc.
|
overridevirtual |
Sets all parameters in the underlying solver.
Implements operations_research::MPSolverInterface.
Definition at line 296 of file knapsack_interface.cc.
|
overridevirtual |
Implements operations_research::MPSolverInterface.
Definition at line 306 of file knapsack_interface.cc.
|
overridevirtual |
Implements operations_research::MPSolverInterface.
Definition at line 302 of file knapsack_interface.cc.
|
overridevirtual |
Sets each parameter in the underlying solver.
Implements operations_research::MPSolverInterface.
Definition at line 300 of file knapsack_interface.cc.
|
overridevirtual |
Sets the scaling mode.
Implements operations_research::MPSolverInterface.
Definition at line 308 of file knapsack_interface.cc.
|
overridevirtual |
Modifies bounds of an extracted variable.
Implements operations_research::MPSolverInterface.
Definition at line 152 of file knapsack_interface.cc.
|
overridevirtual |
Modifies integrality of an extracted variable.
Implements operations_research::MPSolverInterface.
Definition at line 156 of file knapsack_interface.cc.
|
overridevirtual |
--— Solve --—
Implements operations_research::MPSolverInterface.
Definition at line 102 of file knapsack_interface.cc.
|
overridevirtual |
Returns a string describing the underlying solver and its version.
Implements operations_research::MPSolverInterface.
Definition at line 215 of file knapsack_interface.cc.
|
overridevirtual |
Returns the underlying solver.
Implements operations_research::MPSolverInterface.
Definition at line 219 of file knapsack_interface.cc.