CGAL 5.6.3 - CGAL and Solvers

Loading...
Searching...
No Matches
List of all members
MixedIntegerProgramTraits< FT > Concept Reference
CGAL and Solvers Reference » Concepts

## 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.

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

## Member Function Documentation

## ◆ 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().

## ◆ 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.