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

#include <Concepts/MixedIntegerProgramTraits.h>

Definition

template<typename FT>
class MixedIntegerProgramTraits< FT >

Concept describing the set of requirements for (constrained or unconstrained) Mixed Integer Programming (MIP) problems. A model of this concept stores the integer variables, linear objective, and linear constraints (if any) and provides a method to solve the problem.

Has Models:

CGAL::Mixed_integer_program_traits<T>

CGAL::GLPK_mixed_integer_program_traits<T>

CGAL::SCIP_mixed_integer_program_traits<T>

Creation

 MixedIntegerProgramTraits ()
 Default constructor. More...
 

Operations

MixedIntegerProgramVariablecreate_variable (Variable_type type, FT lb, FT ub, const std::string &name)
 Creates a single variable, adds it to the solver, and returns its pointer. More...
 
std::vector< MixedIntegerProgramVariable * > create_variables (std::size_t n)
 Creates a set of variables, adds them to the solver, and returns their pointers. More...
 
MixedIntegerProgramLinearConstraintcreate_constraint (FT lb, FT ub, const std::string &name)
 Creates a single linear constraint, adds it to the solver, and returns the pointer. More...
 
std::vector< MixedIntegerProgramLinearConstraint * > create_constraints (std::size_t n)
 Creates a set of linear constraints, adds them to the solver, and returns their pointers. More...
 
MixedIntegerProgramLinearObjectivecreate_objective (Sense sense)
 Creates the objective function and returns the pointer. More...
 
std::size_t number_of_variables () const
 Returns the number of variables. More...
 
const std::vector< MixedIntegerProgramVariable * > & variables () const
 Returns the variables. More...
 
std::vector< MixedIntegerProgramVariable * > & variables ()
 
std::size_t number_of_constraints () const
 Returns the number of constraints. More...
 
const std::vector< MixedIntegerProgramLinearConstraint * > & constraints () const
 Returns the constraints. More...
 
std::vector< MixedIntegerProgramLinearConstraint * > & constraints ()
 
std::size_t number_of_continuous_variables () const
 Returns the number of continuous variables. More...
 
std::size_t number_of_integer_variables () const
 Returns the number of integer variables. More...
 
std::size_t number_of_binary_variables () const
 Returns the number of binary variables. More...
 
bool is_continuous () const
 Returns true if all variables are continuous. More...
 
bool is_mixed_integer_program () const
 Returns true if this is a mixed integer program. More...
 
bool is_integer_program () const
 Returns true if this is an integer program. More...
 
bool is_binary_program () const
 Returns true if binary program. More...
 
const MixedIntegerProgramLinearObjectiveobjective () const
 Returns the objective. More...
 
MixedIntegerProgramLinearObjectiveobjective ()
 
bool solve ()
 Solves the program. Returns false if failed. More...
 
const std::vector< FT > & solution () const
 Returns the result. More...
 
const std::string & error_message () const
 Returns the error message. More...
 
void clear ()
 Clears all variables, constraints, and the objective. More...
 

Constructor & Destructor Documentation

◆ MixedIntegerProgramTraits()

template<typename FT >
MixedIntegerProgramTraits< FT >::MixedIntegerProgramTraits ( )

Default constructor.

Member Function Documentation

◆ clear()

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

Clears all variables, constraints, and the objective.

◆ constraints() [1/2]

template<typename FT >
std::vector<MixedIntegerProgramLinearConstraint*>& MixedIntegerProgramTraits< FT >::constraints ( )

◆ constraints() [2/2]

template<typename FT >
const std::vector<MixedIntegerProgramLinearConstraint*>& MixedIntegerProgramTraits< FT >::constraints ( ) const

Returns the constraints.

◆ create_constraint()

template<typename FT >
MixedIntegerProgramLinearConstraint* MixedIntegerProgramTraits< FT >::create_constraint ( FT  lb,
FT  ub,
const std::string &  name 
)

Creates a single linear constraint, adds it to the solver, and returns the pointer.

Note
Memory is managed by the solver and will be automatically released when the solver is destroyed.

◆ create_constraints()

template<typename FT >
std::vector<MixedIntegerProgramLinearConstraint*> MixedIntegerProgramTraits< FT >::create_constraints ( std::size_t  n)

Creates a set of linear constraints, adds them to the solver, and returns their pointers.

Note
(1) Constraints will be given default names, e.g., c0, c1... (2) Memory is managed by the solver and will be automatically released when the solver is destroyed.

◆ create_objective()

template<typename FT >
MixedIntegerProgramLinearObjective* MixedIntegerProgramTraits< FT >::create_objective ( Sense  sense)

Creates the objective function and returns the pointer.

Note
Memory is managed by the solver and will be automatically released when the solver is destroyed.

◆ create_variable()

template<typename FT >
MixedIntegerProgramVariable* MixedIntegerProgramTraits< FT >::create_variable ( Variable_type  type,
FT  lb,
FT  ub,
const std::string &  name 
)

Creates a single variable, adds it to the solver, and returns its pointer.

Note
Memory is managed by the solver and will be automatically released.

◆ create_variables()

template<typename FT >
std::vector<MixedIntegerProgramVariable*> MixedIntegerProgramTraits< FT >::create_variables ( std::size_t  n)

Creates a set of variables, adds them to the solver, and returns their pointers.

Note
(1) Variables will be given default names, e.g., x0, x1...; (2) Memory is managed by the solver and will be automatically released when the solver is destroyed.

◆ error_message()

template<typename FT >
const std::string& MixedIntegerProgramTraits< FT >::error_message ( ) const

Returns the error message.

Note
This function should be called after call to solve().

◆ is_binary_program()

template<typename FT >
bool MixedIntegerProgramTraits< FT >::is_binary_program ( ) const

Returns true if binary program.

◆ is_continuous()

template<typename FT >
bool MixedIntegerProgramTraits< FT >::is_continuous ( ) const

Returns true if all variables are continuous.

◆ is_integer_program()

template<typename FT >
bool MixedIntegerProgramTraits< FT >::is_integer_program ( ) const

Returns true if this is an integer program.

◆ is_mixed_integer_program()

template<typename FT >
bool MixedIntegerProgramTraits< FT >::is_mixed_integer_program ( ) const

Returns true if this is a mixed integer program.

◆ number_of_binary_variables()

template<typename FT >
std::size_t MixedIntegerProgramTraits< FT >::number_of_binary_variables ( ) const

Returns the number of binary variables.

◆ number_of_constraints()

template<typename FT >
std::size_t MixedIntegerProgramTraits< FT >::number_of_constraints ( ) const

Returns the number of constraints.

◆ number_of_continuous_variables()

template<typename FT >
std::size_t MixedIntegerProgramTraits< FT >::number_of_continuous_variables ( ) const

Returns the number of continuous variables.

◆ number_of_integer_variables()

template<typename FT >
std::size_t MixedIntegerProgramTraits< FT >::number_of_integer_variables ( ) const

Returns the number of integer variables.

◆ number_of_variables()

template<typename FT >
std::size_t MixedIntegerProgramTraits< FT >::number_of_variables ( ) const

Returns the number of variables.

◆ objective() [1/2]

template<typename FT >
MixedIntegerProgramLinearObjective* MixedIntegerProgramTraits< FT >::objective ( )

◆ objective() [2/2]

template<typename FT >
const MixedIntegerProgramLinearObjective* MixedIntegerProgramTraits< FT >::objective ( ) const

Returns the objective.

◆ solution()

template<typename FT >
const std::vector<FT>& MixedIntegerProgramTraits< FT >::solution ( ) const

Returns the result.

Note
(1) Result is valid only if the solver succeeded. (2) Each entry in the result corresponds to the variable with the same index in the program.

◆ solve()

template<typename FT >
bool MixedIntegerProgramTraits< FT >::solve ( )

Solves the program. Returns false if failed.

◆ variables() [1/2]

template<typename FT >
std::vector<MixedIntegerProgramVariable*>& MixedIntegerProgramTraits< FT >::variables ( )

◆ variables() [2/2]

template<typename FT >
const std::vector<MixedIntegerProgramVariable*>& MixedIntegerProgramTraits< FT >::variables ( ) const

Returns the variables.