# Parma_Polyhedra_Library::LP_Problem Class Reference
[C++ Language Interface]

A Linear Programming problem. More...

List of all members.

## Public Member Functions

| LP_Problem ()
| Default constructor: builds a trivial LP problem.
| LP_Problem (const Constraint_System &cs, const Linear_Expression &obj=Linear_Expression::zero(), Optimization_Mode mode=MAXIMIZATION)
| Builds an LP problem from the constraint system `cs`, the objective function `obj` and optimization mode `mode`.
| LP_Problem (const LP_Problem &y)
| Ordinary copy-constructor.
| ~LP_Problem ()
| Destructor.
LP_Problem & | operator= (const LP_Problem &y)
| Assignment operator.
dimension_type | space_dimension () const
| Returns the space dimension of the current LP problem.
const Constraint_System & | constraints () const
| Returns the constraints defining the current feasible region.
const Linear_Expression & | objective_function () const
| Returns the current objective function.
Optimization_Mode | optimization_mode () const
| Returns the current optimization mode.
void | clear ()
| Resets `*this` to be equal to the trivial LP problem.
void | add_constraint (const Constraint &c)
| Adds a copy of constraint `c` to the current LP problem, increasing the number of space dimensions if needed.
void | add_constraints (const Constraint_System &cs)
| Adds a copy of the constraints in `cs` to the current LP problem, increasing the number of space dimensions if needed.
void | set_objective_function (const Linear_Expression &obj)
| Sets the objective function to `obj`.
void | set_optimization_mode (Optimization_Mode mode)
| Sets the optimization mode to `mode`.
bool | is_satisfiable () const
| Checks satisfiability of `*this`.
LP_Problem_Status | solve () const
| Optimizes the current LP problem using the primal simplex algorithm.
void | evaluate_objective_function (const Generator &evaluating_point, Coefficient &num, Coefficient &den) const
| Sets `num` and `den` so that is the result of evaluating the objective function on `evaluating_point`.
const Generator & | feasible_point () const
| Returns a feasible point for `*this`, if it exists.
const Generator & | optimizing_point () const
| Returns an optimal point for `*this`, if it exists.
void | optimal_value (Coefficient &num, Coefficient &den) const
| Sets `num` and `den` so that is the solution of the optimization problem.
bool | OK () const
| Checks if all the invariants are satisfied.
memory_size_type | total_memory_in_bytes () const
| Returns the total size in bytes of the memory occupied by `*this`.
memory_size_type | external_memory_in_bytes () const
| Returns the size in bytes of the memory managed by `*this`.
void | swap (LP_Problem &y)
| Swaps `*this` with `y`.

## Static Public Member Functions

static dimension_type | max_space_dimension ()
| Returns the maximum space dimension a LP_Problem can handle.

## Detailed Description

A Linear Programming problem.

## Constructor & Destructor Documentation

Parma_Polyhedra_Library::LP_Problem::LP_Problem | ( |  | ) | `[inline]`

Default constructor: builds a trivial LP problem.

The trivial LP problem requires to maximize the objective function on the zero-dimensional vector space under no constraints at all: the origin of the vector space is the optimal solution.

Parma_Polyhedra_Library::LP_Problem::LP_Problem | ( | const Constraint_System & | cs,
|  | const Linear_Expression & | obj = `Linear_Expression::zero()`,
|  | Optimization_Mode | mode = `MAXIMIZATION` |
| ) |  |  | `[inline, explicit]`

Builds an LP problem from the constraint system `cs`, the objective function `obj` and optimization mode `mode`.

Parameters:

  | cs | The constraint system defining the feasible region for the LP problem.
  | obj | The objective function for the LP problem (optional argument with default value ).
  | mode | The optimization mode (optional argument with default value `MAXIMIZATION`).

Exceptions:

  | std::invalid_argument | Thrown if the constraint system contains any strict inequality or if the space dimension of the objective function is strictly greater than the space dimension of the constraint system.

## Member Function Documentation

void Parma_Polyhedra_Library::LP_Problem::add_constraint | ( | const Constraint & | c | ) | `[inline]`

Adds a copy of constraint `c` to the current LP problem, increasing the number of space dimensions if needed.

Exceptions:

  | std::invalid_argument | Thrown if the constraint `c` is a strict inequality.

void Parma_Polyhedra_Library::LP_Problem::add_constraints | ( | const Constraint_System & | cs | ) | `[inline]`

Adds a copy of the constraints in `cs` to the current LP problem, increasing the number of space dimensions if needed.

Exceptions:

  | std::invalid_argument | Thrown if the constraint system `cs` contains any strict inequality.

void Parma_Polyhedra_Library::LP_Problem::set_objective_function | ( | const Linear_Expression & | obj | ) | `[inline]`

Sets the objective function to `obj`.

Exceptions:

  | std::invalid_argument | Thrown if the space dimension of `obj` is strictly greater than the space dimension of `*this`.

bool Parma_Polyhedra_Library::LP_Problem::is_satisfiable | ( |  | ) | const

Checks satisfiability of `*this`.

Returns:
  `true` if and only if the LP problem is satisfiable.

LP_Problem_Status Parma_Polyhedra_Library::LP_Problem::solve | ( |  | ) | const`[inline]`

Optimizes the current LP problem using the primal simplex algorithm.

Returns:
  An LP_Problem_Status flag indicating the outcome of the optimization attempt (unfeasible, unbounded or optimized problem).

void Parma_Polyhedra_Library::LP_Problem::evaluate_objective_function | ( | const Generator & | evaluating_point,
|  | Coefficient & | num,
|  | Coefficient & | den |
| ) |  |  | const

Sets `num` and `den` so that is the result of evaluating the objective function on `evaluating_point`.

Parameters:

  | evaluating_point | The point on which the objective function will be evaluated.
  | num | On exit will contain the numerator of the evaluated value.
  | den | On exit will contain the denominator of the evaluated value.

Exceptions:

  | std::invalid_argument | Thrown if `*this` and `evaluating_point` are dimension-incompatible or if the generator `evaluating_point` is not a point.

const Generator & Parma_Polyhedra_Library::LP_Problem::feasible_point | ( |  | ) | const`[inline]`

Returns a feasible point for `*this`, if it exists.

Exceptions:

  | std::domain_error | Thrown if the LP problem is not satisfiable.

const Generator & Parma_Polyhedra_Library::LP_Problem::optimizing_point | ( |  | ) | const`[inline]`

Returns an optimal point for `*this`, if it exists.

Exceptions:

  | std::domain_error | Thrown if `*this` doesn't not have an optimizing point, i.e., if the LP problem is unbounded or not satisfiable.

void Parma_Polyhedra_Library::LP_Problem::optimal_value | ( | Coefficient & | num,
|  | Coefficient & | den |
| ) |  |  | const`[inline]`

Sets `num` and `den` so that is the solution of the optimization problem.

Exceptions:

  | std::domain_error | Thrown if `*this` doesn't not have an optimizing point, i.e., if the LP problem is unbounded or not satisfiable.