C++ Reference

C++ Reference: Linear solver

MPVariable

Detailed Description

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

Definition at line 1017 of file linear_solver.h.

Public Member Functions

const std::string & name () const
 Returns the name of the variable. More...
 
void SetInteger (bool integer)
 Sets the integrality requirement of the variable. More...
 
bool integer () const
 Returns the integrality requirement of the variable. More...
 
double solution_value () const
 Returns the value of the variable in the current solution. More...
 
int index () const
 Returns the index of the variable in the MPSolver::variables_. More...
 
double lb () const
 Returns the lower bound. More...
 
double ub () const
 Returns the upper bound. More...
 
void SetLB (double lb)
 Sets the lower bound. More...
 
void SetUB (double ub)
 Sets the upper bound. More...
 
void SetBounds (double lb, double ub)
 Sets both the lower and upper bounds. More...
 
double unrounded_solution_value () const
 Advanced usage: unrounded solution value. More...
 
double reduced_cost () const
 Advanced usage: returns the reduced cost of the variable in the current solution (only available for continuous problems). More...
 
MPSolver::BasisStatus basis_status () const
 Advanced usage: returns the basis status of the variable in the current solution (only available for continuous problems). More...
 
int branching_priority () const
 Advanced usage: Certain MIP solvers (e.g. More...
 
void SetBranchingPriority (int priority)
 

Protected Member Functions

 MPVariable (int index, double lb, double ub, bool integer, const std::string &name, MPSolverInterface *const interface_in)
 
void set_solution_value (double value)
 
void set_reduced_cost (double reduced_cost)
 

Constructor & Destructor Documentation

◆ MPVariable()

MPVariable ( int  index,
double  lb,
double  ub,
bool  integer,
const std::string &  name,
MPSolverInterface *const  interface_in 
)
inlineprotected

Definition at line 1108 of file linear_solver.h.

Member Function Documentation

◆ basis_status()

MPSolver::BasisStatus basis_status ( ) const

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

◆ branching_priority()

int branching_priority ( ) const
inline

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.

Definition at line 1085 of file linear_solver.h.

◆ index()

int index ( ) const
inline

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

Definition at line 1038 of file linear_solver.h.

◆ integer()

bool integer ( ) const
inline

Returns the integrality requirement of the variable.

Definition at line 1026 of file linear_solver.h.

◆ lb()

double lb ( ) const
inline

Returns the lower bound.

Definition at line 1041 of file linear_solver.h.

◆ name()

const std::string& name ( ) const
inline

Returns the name of the variable.

Definition at line 1020 of file linear_solver.h.

◆ reduced_cost()

double reduced_cost ( ) const

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

◆ set_reduced_cost()

void set_reduced_cost ( double  reduced_cost)
inlineprotected

Definition at line 1120 of file linear_solver.h.

◆ set_solution_value()

void set_solution_value ( double  value)
inlineprotected

Definition at line 1119 of file linear_solver.h.

◆ SetBounds()

void SetBounds ( double  lb,
double  ub 
)

Sets both the lower and upper bounds.

◆ SetBranchingPriority()

void SetBranchingPriority ( int  priority)

◆ SetInteger()

void SetInteger ( bool  integer)

Sets the integrality requirement of the variable.

◆ SetLB()

void SetLB ( double  lb)
inline

Sets the lower bound.

Definition at line 1047 of file linear_solver.h.

◆ SetUB()

void SetUB ( double  ub)
inline

Sets the upper bound.

Definition at line 1050 of file linear_solver.h.

◆ solution_value()

double solution_value ( ) const

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()

double ub ( ) const
inline

Returns the upper bound.

Definition at line 1044 of file linear_solver.h.

◆ unrounded_solution_value()

double unrounded_solution_value ( ) const

Advanced usage: unrounded solution value.

The returned value won't be rounded to the nearest integer even if the variable is integer.


The documentation for this class was generated from the following file: