CGAL 5.1 - CGAL and Solvers
MixedIntegerProgramLinearConstraint< FT > Class Template Reference

#include <Concepts/MixedIntegerProgramTraits.h>

Definition

template<typename FT>
class MixedIntegerProgramLinearConstraint< FT >

MixedIntegerProgramLinearConstraint is a concept of a linear constraint in a Mixed Integer Programming (MIP) problem.

Has Models:
CGAL::Linear_constraint<FT>

Creation

 MixedIntegerProgramLinearConstraint (MixedIntegerProgramTraits *solver, FT lb, FT ub, const std::string &name, int idx)
 Constructs a linear constraint, initialized with the solver it belongs to, the lower bound, upper bound, name, and index. More...
 

Operations

const std::string & name () const
 Returns the name of the constraint. More...
 
void set_name (const std::string &n)
 Sets the name of the constraint. More...
 
int index () const
 Returns the index of the constraint. More...
 
void set_index (int idx)
 Sets the index of the constraint. More...
 
const MixedIntegerProgramTraitssolver () const
 Returns the solver that owns this constraint. More...
 
MixedIntegerProgramTraitssolver ()
 
void set_lower_bound (FT lb)
 Sets the lower bound. More...
 
void set_upper_bound (FT ub)
 Sets the upper bound. More...
 
void set_bounds (FT lb, FT ub)
 Sets both lower and upper bounds. More...
 
FT lower_bound () const
 Gets the lower bound. More...
 
FT upper_bound () const
 Gets the upper bound. More...
 
void get_bounds (FT &lb, FT &ub) const
 Gets both lower and upper bounds. More...
 
void set_coefficients (const std::unordered_map< const MixedIntegerProgramVariable *, FT > &coeffs)
 Sets the coefficients of the constraint. More...
 
void add_coefficient (const MixedIntegerProgramVariable *var, FT coeff)
 Adds a coefficient to a variable of the constraint. More...
 
const std::unordered_map< const MixedIntegerProgramVariable *, FT > & coefficients () const
 Returns the coefficients of the constraint. More...
 
FT get_coefficient (const MixedIntegerProgramVariable *var) const
 Gets the coefficient of the variable in this constraint. More...
 
void set_offset (FT value)
 Sets the constant term. More...
 
FT offset () const
 Gets the constant term. More...
 
void clear ()
 Clears all variables and sets the constant term to zero. More...
 
static FT infinity ()
 Gets the infinity threshold (e.g., 1e20). More...
 

Constructor & Destructor Documentation

◆ MixedIntegerProgramLinearConstraint()

template<typename FT >
MixedIntegerProgramLinearConstraint< FT >::MixedIntegerProgramLinearConstraint ( MixedIntegerProgramTraits solver,
FT  lb,
FT  ub,
const std::string &  name,
int  idx 
)

Constructs a linear constraint, initialized with the solver it belongs to, the lower bound, upper bound, name, and index.

Member Function Documentation

◆ add_coefficient()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::add_coefficient ( const MixedIntegerProgramVariable var,
FT  coeff 
)

Adds a coefficient to a variable of the constraint.

◆ clear()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::clear ( )

Clears all variables and sets the constant term to zero.

Useful to reuse the object to define a new linear constraint.

◆ coefficients()

template<typename FT >
const std::unordered_map<const MixedIntegerProgramVariable*, FT>& MixedIntegerProgramLinearConstraint< FT >::coefficients ( ) const

Returns the coefficients of the constraint.

◆ get_bounds()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::get_bounds ( FT &  lb,
FT &  ub 
) const

Gets both lower and upper bounds.

◆ get_coefficient()

template<typename FT >
FT MixedIntegerProgramLinearConstraint< FT >::get_coefficient ( const MixedIntegerProgramVariable var) const

Gets the coefficient of the variable in this constraint.

◆ index()

template<typename FT >
int MixedIntegerProgramLinearConstraint< FT >::index ( ) const

Returns the index of the constraint.

◆ infinity()

template<typename FT >
static FT MixedIntegerProgramLinearConstraint< FT >::infinity ( )
static

Gets the infinity threshold (e.g., 1e20).

Values greater than this value are considered as infinity.

◆ lower_bound()

template<typename FT >
FT MixedIntegerProgramLinearConstraint< FT >::lower_bound ( ) const

Gets the lower bound.

◆ name()

template<typename FT >
const std::string& MixedIntegerProgramLinearConstraint< FT >::name ( ) const

Returns the name of the constraint.

◆ offset()

template<typename FT >
FT MixedIntegerProgramLinearConstraint< FT >::offset ( ) const

Gets the constant term.

◆ set_bounds()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::set_bounds ( FT  lb,
FT  ub 
)

Sets both lower and upper bounds.

◆ set_coefficients()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::set_coefficients ( const std::unordered_map< const MixedIntegerProgramVariable *, FT > &  coeffs)

Sets the coefficients of the constraint.

◆ set_index()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::set_index ( int  idx)

Sets the index of the constraint.

◆ set_lower_bound()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::set_lower_bound ( FT  lb)

Sets the lower bound.

◆ set_name()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::set_name ( const std::string &  n)

Sets the name of the constraint.

◆ set_offset()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::set_offset ( FT  value)

Sets the constant term.

◆ set_upper_bound()

template<typename FT >
void MixedIntegerProgramLinearConstraint< FT >::set_upper_bound ( FT  ub)

Sets the upper bound.

◆ solver() [1/2]

template<typename FT >
MixedIntegerProgramTraits* MixedIntegerProgramLinearConstraint< FT >::solver ( )

◆ solver() [2/2]

template<typename FT >
const MixedIntegerProgramTraits* MixedIntegerProgramLinearConstraint< FT >::solver ( ) const

Returns the solver that owns this constraint.

◆ upper_bound()

template<typename FT >
FT MixedIntegerProgramLinearConstraint< FT >::upper_bound ( ) const

Gets the upper bound.