operations_research::MPVariable Class Reference

Detailed Description

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

Definition at line 998 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)
 

Friends

class MPSolver
 
class MPSolverInterface
 
class CBCInterface
 
class CLPInterface
 
class GLPKInterface
 
class SCIPInterface
 
class SLMInterface
 
class GurobiInterface
 
class CplexInterface
 
class GLOPInterface
 
class MPVariableSolutionValueTest
 
class BopInterface
 
class SatInterface
 
class KnapsackInterface
 

Constructor & Destructor Documentation

◆ MPVariable()

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

Definition at line 1090 of file linear_solver.h.

Member Function Documentation

◆ basis_status()

MPSolver::BasisStatus operations_research::MPVariable::basis_status ( ) const

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

See also
MPSolver::BasisStatus.

◆ branching_priority()

int operations_research::MPVariable::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 1068 of file linear_solver.h.

◆ index()

int operations_research::MPVariable::index ( ) const
inline

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

Definition at line 1019 of file linear_solver.h.

◆ integer()

bool operations_research::MPVariable::integer ( ) const
inline

Returns the integrality requirement of the variable.

Definition at line 1007 of file linear_solver.h.

◆ lb()

double operations_research::MPVariable::lb ( ) const
inline

Returns the lower bound.

Definition at line 1022 of file linear_solver.h.

◆ name()

const std::string& operations_research::MPVariable::name ( ) const
inline

Returns the name of the variable.

Definition at line 1001 of file linear_solver.h.

◆ reduced_cost()

double operations_research::MPVariable::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 operations_research::MPVariable::set_reduced_cost ( double  reduced_cost)
inlineprotected

Definition at line 1102 of file linear_solver.h.

◆ set_solution_value()

void operations_research::MPVariable::set_solution_value ( double  value)
inlineprotected

Definition at line 1101 of file linear_solver.h.

◆ SetBounds()

void operations_research::MPVariable::SetBounds ( double  lb,
double  ub 
)

Sets both the lower and upper bounds.

◆ SetBranchingPriority()

void operations_research::MPVariable::SetBranchingPriority ( int  priority)

◆ SetInteger()

void operations_research::MPVariable::SetInteger ( bool  integer)

Sets the integrality requirement of the variable.

◆ SetLB()

void operations_research::MPVariable::SetLB ( double  lb)
inline

Sets the lower bound.

Definition at line 1028 of file linear_solver.h.

◆ SetUB()

void operations_research::MPVariable::SetUB ( double  ub)
inline

Sets the upper bound.

Definition at line 1031 of file linear_solver.h.

◆ solution_value()

double operations_research::MPVariable::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 operations_research::MPVariable::ub ( ) const
inline

Returns the upper bound.

Definition at line 1025 of file linear_solver.h.

◆ unrounded_solution_value()

double operations_research::MPVariable::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.

Friends And Related Function Documentation

◆ BopInterface

friend class BopInterface
friend

Definition at line 1083 of file linear_solver.h.

◆ CBCInterface

friend class CBCInterface
friend

Definition at line 1074 of file linear_solver.h.

◆ CLPInterface

friend class CLPInterface
friend

Definition at line 1075 of file linear_solver.h.

◆ CplexInterface

friend class CplexInterface
friend

Definition at line 1080 of file linear_solver.h.

◆ GLOPInterface

friend class GLOPInterface
friend

Definition at line 1081 of file linear_solver.h.

◆ GLPKInterface

friend class GLPKInterface
friend

Definition at line 1076 of file linear_solver.h.

◆ GurobiInterface

friend class GurobiInterface
friend

Definition at line 1079 of file linear_solver.h.

◆ KnapsackInterface

friend class KnapsackInterface
friend

Definition at line 1085 of file linear_solver.h.

◆ MPSolver

friend class MPSolver
friend

Definition at line 1072 of file linear_solver.h.

◆ MPSolverInterface

friend class MPSolverInterface
friend

Definition at line 1073 of file linear_solver.h.

◆ MPVariableSolutionValueTest

friend class MPVariableSolutionValueTest
friend

Definition at line 1082 of file linear_solver.h.

◆ SatInterface

friend class SatInterface
friend

Definition at line 1084 of file linear_solver.h.

◆ SCIPInterface

friend class SCIPInterface
friend

Definition at line 1077 of file linear_solver.h.

◆ SLMInterface

friend class SLMInterface
friend

Definition at line 1078 of file linear_solver.h.


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