PPL
1.2
|
A Parametric Integer (linear) Programming problem. More...
#include <ppl.hh>
Public Types | |
enum | Control_Parameter_Name { CUTTING_STRATEGY, PIVOT_ROW_STRATEGY } |
Possible names for PIP_Problem control parameters. More... | |
enum | Control_Parameter_Value { CUTTING_STRATEGY_FIRST, CUTTING_STRATEGY_DEEPEST, CUTTING_STRATEGY_ALL, PIVOT_ROW_STRATEGY_FIRST, PIVOT_ROW_STRATEGY_MAX_COLUMN } |
Possible values for PIP_Problem control parameters. More... | |
typedef Constraint_Sequence::const_iterator | const_iterator |
A type alias for the read-only iterator on the constraints defining the feasible region. | |
Public Member Functions | |
PIP_Problem (dimension_type dim=0) | |
Builds a trivial PIP problem. More... | |
template<typename In > | |
PIP_Problem (dimension_type dim, In first, In last, const Variables_Set &p_vars) | |
Builds a PIP problem having space dimension dim from the sequence of constraints in the range ![]() p_vars are interpreted as parameters. More... | |
PIP_Problem (const PIP_Problem &y) | |
Ordinary copy-constructor. | |
~PIP_Problem () | |
Destructor. | |
PIP_Problem & | operator= (const PIP_Problem &y) |
Assignment operator. | |
dimension_type | space_dimension () const |
Returns the space dimension of the PIP problem. | |
const Variables_Set & | parameter_space_dimensions () const |
Returns a set containing all the variables' indexes representing the parameters of the PIP problem. | |
const_iterator | constraints_begin () const |
Returns a read-only iterator to the first constraint defining the feasible region. | |
const_iterator | constraints_end () const |
Returns a past-the-end read-only iterator to the sequence of constraints defining the feasible region. | |
void | clear () |
Resets *this to be equal to the trivial PIP problem. More... | |
void | add_space_dimensions_and_embed (dimension_type m_vars, dimension_type m_params) |
Adds m_vars + m_params new space dimensions and embeds the old PIP problem in the new vector space. More... | |
void | add_to_parameter_space_dimensions (const Variables_Set &p_vars) |
Sets the space dimensions whose indexes which are in set p_vars to be parameter space dimensions. More... | |
void | add_constraint (const Constraint &c) |
Adds a copy of constraint c to the PIP problem. More... | |
void | add_constraints (const Constraint_System &cs) |
Adds a copy of the constraints in cs to the PIP problem. More... | |
bool | is_satisfiable () const |
Checks satisfiability of *this . More... | |
PIP_Problem_Status | solve () const |
Optimizes the PIP problem. More... | |
PIP_Tree | solution () const |
Returns a feasible solution for *this , if it exists. More... | |
PIP_Tree | optimizing_solution () const |
Returns an optimizing solution for *this , if it exists. More... | |
bool | OK () const |
Checks if all the invariants are satisfied. | |
void | print_solution (std::ostream &s, int indent=0) const |
Prints on s the solution computed for *this . More... | |
void | ascii_dump () const |
Writes to std::cerr an ASCII representation of *this . | |
void | ascii_dump (std::ostream &s) const |
Writes to s an ASCII representation of *this . | |
void | print () const |
Prints *this to std::cerr using operator<< . | |
bool | ascii_load (std::istream &s) |
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this accordingly. Returns true if successful, false otherwise. | |
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 | m_swap (PIP_Problem &y) |
Swaps *this with y . | |
Control_Parameter_Value | get_control_parameter (Control_Parameter_Name name) const |
Returns the value of control parameter name . | |
void | set_control_parameter (Control_Parameter_Value value) |
Sets control parameter value . | |
void | set_big_parameter_dimension (dimension_type big_dim) |
Sets the dimension for the big parameter to big_dim . | |
dimension_type | get_big_parameter_dimension () const |
Returns the space dimension for the big parameter. More... | |
Static Public Member Functions | |
static dimension_type | max_space_dimension () |
Returns the maximum space dimension a PIP_Problem can handle. | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &s, const PIP_Problem &pip) |
Output operator. More... | |
void | swap (PIP_Problem &x, PIP_Problem &y) |
Swaps x with y . More... | |
void | swap (PIP_Problem &x, PIP_Problem &y) |
A Parametric Integer (linear) Programming problem.
An object of this class encodes a parametric integer (linear) programming problem. The PIP problem is specified by providing:
Note that all problem variables and problem parameters are assumed to take non-negative integer values, so that there is no need to specify non-negativity constraints.
The class provides support for the (incremental) solution of the PIP problem based on variations of the revised simplex method and on Gomory cut generation techniques.
The solution for a PIP problem is the lexicographic minimum of the integer points of the feasible region, expressed in terms of the parameters. As the problem to be solved only involves non-negative variables and parameters, the problem will always be either unfeasible or optimizable.
As the feasibility and the solution value of a PIP problem depend on the values of the parameters, the solution is a binary decision tree, dividing the context parameter set into subsets. The tree nodes are of two kinds:
It may happen that a decision node has no false child. This means that there is no solution if at least one of the corresponding constraints is not satisfied. Decision nodes having two or more linear tests on the parameters cannot have a false child. Decision nodes always have a true child.
Both kinds of tree nodes may also contain the definition of extra parameters which are artificially introduced by the solver to enforce an integral solution. Such artificial parameters are defined by the integer division of a linear expression on the parameters by an integer coefficient.
By exploiting the incremental nature of the solver, it is possible to reuse part of the computational work already done when solving variants of a given PIP_Problem: currently, incremental resolution supports the addition of space dimensions, the addition of parameters and the addition of constraints.
i
and j
are the problem variables and n
and m
are the problem parameters. This problem can be optimized; the resulting solution tree may be represented as follows: if 7*n >= 10 then if 7*m >= 12 then {i = 2 ; j = 2} else Parameter P = (m) div 2 if 2*n + 3*m >= 8 then {i = -m - P + 4 ; j = m} else _|_ else _|_The solution tree starts with a decision node depending on the context constraint
7*n >= 10
. If this constraint is satisfied by the values assigned to the problem parameters, then the (textually first) then
branch is taken, reaching the true child of the root node (which in this case is another decision node); otherwise, the (textually last) else
branch is taken, for which there is no corresponding false child. P
in the (textually first) else
branch above. These artificial parameters are only meaningful inside the subtree where they are defined and are used to define the parametric values of the problem variables in solution nodes (e.g., the {i,j}
vector in the textually third then
branch).{i = 2 ; j = 2}
status
indicates if the problem has been optimized or if it is unfeasible for any possible configuration of the parameter values. The resolution process is also started if an attempt is made to get its solution, as follows: node
.Variable::set_output_function
): if 7*C >= 10 then if 7*D >= 12 then {2 ; 2} else Parameter E = (D) div 2 if 2*C + 3*D >= 8 then {-D - E + 4 ; D} else _|_ else _|_
node
represents an unfeasible solution (i.e., 0
. For a non-null tree node, the virtual methods PIP_Tree_Node::as_decision()
and PIP_Tree_Node::as_solution()
can be used to check whether the node is a decision or a solution node: PIP_Decision_Node::child_node(bool)
, passing true
(resp., false
) as the input argument.dim+1
, where the value of dim
is computed as follows:dim
is the space dimension of the PIP_Problem;dim
computed for the parent node to the number of artificial parameters defined in the parent node.
Parameter E = (C + 1) div 3 {D - E - 1 ; -C + D + E + 1}Under the notations above, the solution is:
Parameter E = (2*C + 3) div 5 {D - E - 1 ; D + 2*E - 2}Under the notations above, the solution is:
|
explicit |
Builds a trivial PIP problem.
A trivial PIP problem requires to compute the lexicographic minimum on a vector space under no constraints and with no parameters: due to the implicit non-negativity constraints, the origin of the vector space is an optimal solution.
dim | The dimension of the vector space enclosing *this (optional argument with default value ![]() |
std::length_error | Thrown if dim exceeds max_space_dimension() . |
Parma_Polyhedra_Library::PIP_Problem::PIP_Problem | ( | dimension_type | dim, |
In | first, | ||
In | last, | ||
const Variables_Set & | p_vars | ||
) |
Builds a PIP problem having space dimension dim
from the sequence of constraints in the range ; those dimensions whose indices occur in
p_vars
are interpreted as parameters.
dim | The dimension of the vector space (variables and parameters) enclosing *this . |
first | An input iterator to the start of the sequence of constraints. |
last | A past-the-end input iterator to the sequence of constraints. |
p_vars | The set of variables' indexes that are interpreted as parameters. |
std::length_error | Thrown if dim exceeds max_space_dimension() . |
std::invalid_argument | Thrown if the space dimension of a constraint in the sequence (resp., the parameter variables) is strictly greater than dim . |
void Parma_Polyhedra_Library::PIP_Problem::clear | ( | ) |
Resets *this
to be equal to the trivial PIP problem.
The space dimension is reset to .
void Parma_Polyhedra_Library::PIP_Problem::add_space_dimensions_and_embed | ( | dimension_type | m_vars, |
dimension_type | m_params | ||
) |
Adds m_vars + m_params
new space dimensions and embeds the old PIP problem in the new vector space.
m_vars | The number of space dimensions to add that are interpreted as PIP problem variables (i.e., non parameters). These are added before adding the m_params parameters. |
m_params | The number of space dimensions to add that are interpreted as PIP problem parameters. These are added after having added the m_vars problem variables. |
std::length_error | Thrown if adding m_vars + m_params new space dimensions would cause the vector space to exceed dimension max_space_dimension() . |
The new space dimensions will be those having the highest indexes in the new PIP problem; they are initially unconstrained.
void Parma_Polyhedra_Library::PIP_Problem::add_to_parameter_space_dimensions | ( | const Variables_Set & | p_vars | ) |
Sets the space dimensions whose indexes which are in set p_vars
to be parameter space dimensions.
std::invalid_argument | Thrown if some index in p_vars does not correspond to a space dimension in *this . |
void Parma_Polyhedra_Library::PIP_Problem::add_constraint | ( | const Constraint & | c | ) |
Adds a copy of constraint c
to the PIP problem.
std::invalid_argument | Thrown if the space dimension of c is strictly greater than the space dimension of *this . |
void Parma_Polyhedra_Library::PIP_Problem::add_constraints | ( | const Constraint_System & | cs | ) |
Adds a copy of the constraints in cs
to the PIP problem.
std::invalid_argument | Thrown if the space dimension of constraint system cs is strictly greater than the space dimension of *this . |
bool Parma_Polyhedra_Library::PIP_Problem::is_satisfiable | ( | ) | const |
Checks satisfiability of *this
.
true
if and only if the PIP problem is satisfiable. PIP_Problem_Status Parma_Polyhedra_Library::PIP_Problem::solve | ( | ) | const |
Optimizes the PIP problem.
PIP_Tree Parma_Polyhedra_Library::PIP_Problem::solution | ( | ) | const |
Returns a feasible solution for *this
, if it exists.
A null pointer is returned for an unfeasible PIP problem.
PIP_Tree Parma_Polyhedra_Library::PIP_Problem::optimizing_solution | ( | ) | const |
Returns an optimizing solution for *this
, if it exists.
A null pointer is returned for an unfeasible PIP problem.
void Parma_Polyhedra_Library::PIP_Problem::print_solution | ( | std::ostream & | s, |
int | indent = 0 |
||
) | const |
Prints on s
the solution computed for *this
.
s | The output stream. |
indent | An indentation parameter (default value 0). |
std::logic_error | Thrown if trying to print the solution when the PIP problem still has to be solved. |
|
inline |
Returns the space dimension for the big parameter.
If a big parameter was not set, returns not_a_dimension()
.
|
related |
Output operator.
|
related |
Swaps x
with y
.
|
related |