C++ Reference: class MPVariable

This documentation is automatically generated.

The class for variables of a Mathematical Programming (MP) model.
Method
basis_status

Return type: MPSolver::BasisStatus

Advanced usage: returns the basis status of the variable in the current solution (only available for continuous problems). @see MPSolver::BasisStatus.

branching_priority

Return type: int

Advanced usage: Certain MIP solvers (e.g. Gurobi or SCIP) allow you to set a per-variable priority for determining which variable to branch on. A value of 0 is treated as default, and is equivalent to not setting the branching priority. The solver looks first to branch on fractional variables in higher priority levels. As of 2019-05, only Gurobi and SCIP support setting branching priority; all other solvers will simply ignore this annotation.

index

Return type: int

Returns the index of the variable in the MPSolver::variables_.

integer

Return type: bool

Returns the integrality requirement of the variable.

lb

Return type: double

Returns the lower bound.

name

Return type: const std::string&

Returns the name of the variable.

reduced_cost

Return type: double

Advanced usage: returns the reduced cost of the variable in the current solution (only available for continuous problems).

SetBounds

Return type: void

Arguments: double lb, double ub

Sets both the lower and upper bounds.

SetBranchingPriority

Return type: void

Arguments: int priority

SetInteger

Return type: void

Arguments: bool integer

Sets the integrality requirement of the variable.

SetLB

Return type: void

Arguments: double lb

Sets the lower bound.

SetUB

Return type: void

Arguments: double ub

Sets the upper bound.

solution_value

Return type: double

Returns the value of the variable in the current solution. If the variable is integer, then the value will always be an integer (the underlying solver handles floating-point values only, but this function automatically rounds it to the nearest integer; see: man 3 round).

ub

Return type: double

Returns the upper bound.

unrounded_solution_value

Return type: double

Advanced usage: unrounded solution value. The returned value won't be rounded to the nearest integer even if the variable is integer.