C++ Reference: class MPSolverInterface

This documentation is automatically generated.

This class wraps the actual mathematical programming solvers. Each solver (GLOP, CLP, CBC, GLPK, SCIP) has its own interface class that derives from this abstract class. This class is never directly accessed by the user. @see glop_interface.cc @see cbc_interface.cc @see clp_interface.cc @see glpk_interface.cc @see scip_interface.cc
Method
AddRowConstraint

Return type: virtual void

Arguments: MPConstraint* const ct

Adds a linear constraint.

AddVariable

Return type: virtual void

Arguments: MPVariable* const var

Add a variable.

best_objective_bound

Return type: virtual double

Returns the best objective bound. The problem must be discrete, otherwise it crashes, or returns trivial_worst_objective_bound() in NDEBUG mode.

CheckBestObjectiveBoundExists

Return type: virtual bool

Checks whether information on the best objective bound exists. The behavior is similar to CheckSolutionIsSynchronized() above.

CheckSolutionExists

Return type: virtual bool

Checks whether a feasible solution exists. The behavior is similar to CheckSolutionIsSynchronized() above.

CheckSolutionIsSynchronized

Return type: bool

Checks whether the solution is synchronized with the model, i.e. whether the model has changed since the solution was computed last. If it isn't, it crashes in NDEBUG, and returns false othwerwise.

CheckSolutionIsSynchronizedAndExists

Return type: bool

Handy shortcut to do both checks above (it is often used).

ClearConstraint

Return type: virtual void

Arguments: MPConstraint* const constraint

Clears a constraint from all its terms.

ClearObjective

Return type: virtual void

Clears the objective from all its terms.

column_status

Return type: virtual MPSolver::BasisStatus

Arguments: int variable_index

Returns the basis status of a constraint.

ComputeExactConditionNumber

Return type: virtual double

Computes exact condition number. Only available for continuous problems and only implemented in GLPK.

constraint_is_extracted

Return type: bool

Arguments: int ct_index

InterruptSolve

Return type: virtual bool

IsContinuous

Return type: virtual bool

----- 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.

IsLP

Return type: virtual bool

Returns true if the problem is continuous and linear.

IsMIP

Return type: virtual bool

Returns true if the problem is discrete and linear.

iterations

Return type: virtual int64

------ 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.

last_variable_index

Return type: int

Returns the index of the last variable extracted.

MPSolverInterface

Return type: explicit

Arguments: MPSolver* const solver

Constructor. The user will access the MPSolverInterface through the MPSolver passed as argument.

~MPSolverInterface

Return type: virtual

NextSolution

Return type: virtual bool

See MPSolver::NextSolution() for contract.

nodes

Return type: virtual int64

Returns the number of branch-and-bound nodes. The problem must be discrete, otherwise it crashes, or returns kUnknownNumberOfNodes in NDEBUG mode.

objective_value

Return type: double

Returns the objective value of the best solution found so far.

quiet

Return type: bool

Returns the boolean indicating the verbosity of the solver output.

Reset

Return type: virtual void

----- Model modifications and extraction ----- Resets extracted model.

result_status

Return type: MPSolver::ResultStatus

Returns the result status of the last solve.

row_status

Return type: virtual MPSolver::BasisStatus

Arguments: int constraint_index

Returns the basis status of a row.

set_constraint_as_extracted

Return type: void

Arguments: int ct_index, bool extracted

set_quiet

Return type: void

Arguments: bool quiet_value

Sets the boolean indicating the verbosity of the solver output.

set_variable_as_extracted

Return type: void

Arguments: int var_index, bool extracted

SetCoefficient

Return type: virtual void

Arguments: MPConstraint* const constraint, const MPVariable* const variable, double new_value, double old_value

Changes a coefficient in a constraint.

SetConstraintBounds

Return type: virtual void

Arguments: int index, double lb, double ub

Modify bounds of an extracted variable.

SetObjectiveCoefficient

Return type: virtual void

Arguments: const MPVariable* const variable, double coefficient

Changes a coefficient in the linear objective.

SetObjectiveOffset

Return type: virtual void

Arguments: double value

Changes the constant term in the linear objective.

SetOptimizationDirection

Return type: virtual void

Arguments: bool maximize

Sets the optimization direction (min/max).

SetStartingLpBasis

Return type: virtual void

Arguments: const std::vector<MPSolver::BasisStatus>& variable_statuses, const std::vector<MPSolver::BasisStatus>& constraint_statuses

See MPSolver::SetStartingLpBasis().

SetVariableBounds

Return type: virtual void

Arguments: int index, double lb, double ub

Modifies bounds of an extracted variable.

SetVariableInteger

Return type: virtual void

Arguments: int index, bool integer

Modifies integrality of an extracted variable.

Solve

Return type: virtual MPSolver::ResultStatus

Arguments: const MPSolverParameters& param

----- Solve ----- Solves problem with specified parameter values. Returns true if the solution is optimal.

SolverVersion

Return type: virtual std::string

Returns a std::string describing the underlying solver and its version.

trivial_worst_objective_bound

Return type: double

A trivial objective bound: the worst possible value of the objective, which will be +infinity if minimizing and -infinity if maximing.

underlying_solver

Return type: virtual void*

Returns the underlying solver.

variable_is_extracted

Return type: bool

Arguments: int var_index

Write

Return type: virtual void

Arguments: const std::string& filename

Writes the model using the solver internal write function. Currently only available for GurobiInterface.

Send feedback about...