PPL
1.2
|
A node of the PIP solution tree. More...
#include <PIP_Tree_defs.hh>
Classes | |
class | Artificial_Parameter |
Artificial parameters in PIP solution trees. More... | |
Public Types | |
typedef Sparse_Row | Row |
typedef std::vector< Artificial_Parameter > | Artificial_Parameter_Sequence |
A type alias for a sequence of Artificial_Parameter's. More... | |
Public Member Functions | |
virtual PIP_Tree_Node * | clone () const =0 |
Returns a pointer to a dynamically-allocated copy of *this . More... | |
virtual | ~PIP_Tree_Node () |
Destructor. More... | |
virtual bool | OK () const =0 |
Returns true if and only if *this is well formed. More... | |
virtual const PIP_Solution_Node * | as_solution () const =0 |
Returns this if *this is a solution node, 0 otherwise. More... | |
virtual const PIP_Decision_Node * | as_decision () const =0 |
Returns this if *this is a decision node, 0 otherwise. More... | |
const Constraint_System & | constraints () const |
Returns the system of parameter constraints controlling *this . More... | |
Artificial_Parameter_Sequence::const_iterator | art_parameter_begin () const |
Returns a const_iterator to the beginning of local artificial parameters. More... | |
Artificial_Parameter_Sequence::const_iterator | art_parameter_end () const |
Returns a const_iterator to the end of local artificial parameters. More... | |
dimension_type | art_parameter_count () const |
Returns the number of local artificial parameters. More... | |
void | print (std::ostream &s, int indent=0) const |
Prints on s the tree rooted in *this . More... | |
void | ascii_dump (std::ostream &s) const |
Dumps to s an ASCII representation of *this . More... | |
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. More... | |
virtual memory_size_type | total_memory_in_bytes () const =0 |
Returns the total size in bytes of the memory occupied by *this . More... | |
virtual memory_size_type | external_memory_in_bytes () const =0 |
Returns the size in bytes of the memory managed by *this . More... | |
Protected Types | |
typedef std::vector< Constraint > | Constraint_Sequence |
A type alias for a sequence of constraints. More... | |
Protected Member Functions | |
PIP_Tree_Node (const PIP_Problem *owner) | |
Constructor: builds a node owned by *owner . More... | |
PIP_Tree_Node (const PIP_Tree_Node &y) | |
Copy constructor. More... | |
const PIP_Problem * | get_owner () const |
Returns a pointer to the PIP_Problem owning object. More... | |
virtual void | set_owner (const PIP_Problem *owner)=0 |
Sets the pointer to the PIP_Problem owning object. More... | |
virtual bool | check_ownership (const PIP_Problem *owner) const =0 |
Returns true if and only if all the nodes in the subtree rooted in *this are owned by *owner . More... | |
const PIP_Decision_Node * | parent () const |
Returns a pointer to this node's parent. More... | |
void | set_parent (const PIP_Decision_Node *p) |
Set this node's parent to *p . More... | |
virtual void | update_tableau (const PIP_Problem &pip, dimension_type external_space_dim, dimension_type first_pending_constraint, const Constraint_Sequence &input_cs, const Variables_Set ¶meters)=0 |
Populates the parametric simplex tableau using external data. More... | |
virtual PIP_Tree_Node * | solve (const PIP_Problem &pip, bool check_feasible_context, const Matrix< Row > &context, const Variables_Set ¶ms, dimension_type space_dim, int indent_level)=0 |
Executes a parametric simplex on the tableau, under specified context. More... | |
void | add_constraint (const Row &row, const Variables_Set ¶meters) |
Inserts a new parametric constraint in internal row format. More... | |
void | parent_merge () |
Merges parent's artificial parameters into *this . More... | |
virtual void | print_tree (std::ostream &s, int indent, const std::vector< bool > &pip_dim_is_param, dimension_type first_art_dim) const =0 |
Prints on s the tree rooted in *this . More... | |
Static Protected Member Functions | |
static void | indent_and_print (std::ostream &s, int indent, const char *str) |
A helper function used when printing PIP trees. More... | |
static bool | compatibility_check (Matrix< Row > &s) |
Checks whether a context matrix is satisfiable. More... | |
static bool | compatibility_check (const Matrix< Row > &context, const Row &row) |
Helper method: checks for satisfiability of the restricted context obtained by adding row to context . More... | |
Protected Attributes | |
const PIP_Problem * | owner_ |
A pointer to the PIP_Problem object owning this node. More... | |
const PIP_Decision_Node * | parent_ |
A pointer to the parent of *this , null if *this is the root. More... | |
Constraint_System | constraints_ |
The local system of parameter constraints. More... | |
Artificial_Parameter_Sequence | artificial_parameters |
The local sequence of expressions for local artificial parameters. More... | |
Friends | |
class | PIP_Problem |
class | PIP_Decision_Node |
class | PIP_Solution_Node |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &os, const PIP_Tree_Node &x) |
Output operator: prints the solution tree rooted in x . More... | |
A node of the PIP solution tree.
This is the base class for the nodes of the binary trees representing the solutions of PIP problems. From this one, two classes are derived:
Definition at line 50 of file PIP_Tree_defs.hh.
typedef std::vector<Artificial_Parameter> Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter_Sequence |
A type alias for a sequence of Artificial_Parameter's.
Definition at line 101 of file PIP_Tree_defs.hh.
|
protected |
A type alias for a sequence of constraints.
Definition at line 142 of file PIP_Tree_defs.hh.
Definition at line 72 of file PIP_Tree_defs.hh.
|
explicitprotected |
Constructor: builds a node owned by *owner
.
Definition at line 916 of file PIP_Tree.cc.
|
protected |
Copy constructor.
Definition at line 923 of file PIP_Tree.cc.
|
virtual |
|
protected |
Inserts a new parametric constraint in internal row format.
Definition at line 1222 of file PIP_Tree.cc.
References Parma_Polyhedra_Library::add_mul_assign(), Parma_Polyhedra_Library::Sparse_Row::begin(), constraints_, Parma_Polyhedra_Library::Sparse_Row::end(), Parma_Polyhedra_Library::Sparse_Row::get(), Parma_Polyhedra_Library::CO_Tree::const_iterator::index(), Parma_Polyhedra_Library::Constraint_System::insert(), WEIGHT_ADD, and WEIGHT_BEGIN.
Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::solve().
|
inline |
Returns a const_iterator to the beginning of local artificial parameters.
Definition at line 76 of file PIP_Tree_inlines.hh.
References artificial_parameters.
Referenced by external_memory_in_bytes(), parent_merge(), and print_tree().
|
inline |
Returns the number of local artificial parameters.
Definition at line 86 of file PIP_Tree_inlines.hh.
References artificial_parameters.
Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::print_tree().
|
inline |
Returns a const_iterator to the end of local artificial parameters.
Definition at line 81 of file PIP_Tree_inlines.hh.
References artificial_parameters.
Referenced by external_memory_in_bytes(), parent_merge(), and print_tree().
|
pure virtual |
Returns this
if *this
is a decision node, 0 otherwise.
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
|
pure virtual |
Returns this
if *this
is a solution node, 0 otherwise.
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
void Parma_Polyhedra_Library::PIP_Tree_Node::ascii_dump | ( | std::ostream & | s | ) | const |
Dumps to s
an ASCII representation of *this
.
Definition at line 1818 of file PIP_Tree.cc.
References artificial_parameters, Parma_Polyhedra_Library::Constraint_System::ascii_dump(), and constraints_.
Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::ascii_dump(), and Parma_Polyhedra_Library::PIP_Decision_Node::ascii_dump().
bool Parma_Polyhedra_Library::PIP_Tree_Node::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.
Definition at line 1830 of file PIP_Tree.cc.
References artificial_parameters, Parma_Polyhedra_Library::Constraint_System::ascii_load(), Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::ascii_load(), and constraints_.
Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::ascii_load(), and Parma_Polyhedra_Library::PIP_Decision_Node::ascii_load().
|
protectedpure virtual |
Returns true
if and only if all the nodes in the subtree rooted in *this
are owned by *owner
.
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::check_ownership().
|
pure virtual |
Returns a pointer to a dynamically-allocated copy of *this
.
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::PIP_Decision_Node(), and Parma_Polyhedra_Library::PIP_Problem::PIP_Problem().
|
staticprotected |
Checks whether a context matrix is satisfiable.
The satisfiability check is implemented by the revised dual simplex algorithm on the context matrix. The algorithm ensures the feasible solution is integer by applying a cut generation method when intermediate non-integer solutions are found.
Definition at line 2195 of file PIP_Tree.cc.
References Parma_Polyhedra_Library::Matrix< Row >::add_zero_rows(), Parma_Polyhedra_Library::PIP_Solution_Node::basis, Parma_Polyhedra_Library::Sparse_Row::begin(), Parma_Polyhedra_Library::Sparse_Row::end(), Parma_Polyhedra_Library::exact_div_assign(), Parma_Polyhedra_Library::gcd_assign(), Parma_Polyhedra_Library::Sparse_Row::get(), Parma_Polyhedra_Library::PIP_Solution_Node::mapping, Parma_Polyhedra_Library::maybe_abandon(), Parma_Polyhedra_Library::not_a_dimension(), Parma_Polyhedra_Library::Matrix< Row >::num_columns(), Parma_Polyhedra_Library::Matrix< Row >::num_rows(), Parma_Polyhedra_Library::Matrix< Row >::OK(), PPL_DIRTY_TEMP_COEFFICIENT, Parma_Polyhedra_Library::Matrix< Row >::remove_trailing_rows(), Parma_Polyhedra_Library::swap(), Parma_Polyhedra_Library::PIP_Solution_Node::var_column, Parma_Polyhedra_Library::PIP_Solution_Node::var_row, WEIGHT_ADD, and WEIGHT_BEGIN.
Referenced by compatibility_check(), Parma_Polyhedra_Library::PIP_Problem::solve(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().
|
staticprotected |
Helper method: checks for satisfiability of the restricted context obtained by adding row
to context
.
Definition at line 2187 of file PIP_Tree.cc.
References Parma_Polyhedra_Library::Matrix< Row >::add_row(), and compatibility_check().
|
inline |
Returns the system of parameter constraints controlling *this
.
The indices in the constraints are the same as the original variables and parameters. Coefficients in indices corresponding to variables always are zero.
Definition at line 71 of file PIP_Tree_inlines.hh.
References constraints_.
|
pure virtual |
Returns the size in bytes of the memory managed by *this
.
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
Definition at line 3741 of file PIP_Tree.cc.
References art_parameter_begin(), art_parameter_end(), artificial_parameters, constraints_, and Parma_Polyhedra_Library::Constraint_System::external_memory_in_bytes().
Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::external_memory_in_bytes(), and Parma_Polyhedra_Library::PIP_Decision_Node::external_memory_in_bytes().
|
inlineprotected |
Returns a pointer to the PIP_Problem owning object.
Definition at line 66 of file PIP_Tree_inlines.hh.
References owner_.
Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::check_ownership(), Parma_Polyhedra_Library::PIP_Decision_Node::check_ownership(), Parma_Polyhedra_Library::PIP_Solution_Node::parametric_values(), print(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Solution_Node::update_solution().
|
staticprotected |
A helper function used when printing PIP trees.
Definition at line 3803 of file PIP_Tree.cc.
Referenced by Parma_Polyhedra_Library::PIP_Problem::print_solution(), print_tree(), Parma_Polyhedra_Library::PIP_Solution_Node::print_tree(), Parma_Polyhedra_Library::PIP_Decision_Node::print_tree(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().
|
pure virtual |
Returns true
if and only if *this
is well formed.
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
Definition at line 1197 of file PIP_Tree.cc.
References Parma_Polyhedra_Library::PIP_Solution_Node::ascii_dump(), Parma_Polyhedra_Library::Constraint_System::begin(), constraints_, and Parma_Polyhedra_Library::Constraint_System::end().
Referenced by Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::ascii_load(), Parma_Polyhedra_Library::PIP_Solution_Node::OK(), Parma_Polyhedra_Library::PIP_Decision_Node::OK(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().
|
inlineprotected |
Returns a pointer to this node's parent.
Definition at line 61 of file PIP_Tree_inlines.hh.
References parent_.
Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::generate_cut(), parent_merge(), print(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().
|
protected |
Merges parent's artificial parameters into *this
.
Definition at line 1251 of file PIP_Tree.cc.
References art_parameter_begin(), art_parameter_end(), artificial_parameters, Parma_Polyhedra_Library::PIP_Solution_Node::OK(), parent(), and parent_.
Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::solve().
void Parma_Polyhedra_Library::PIP_Tree_Node::print | ( | std::ostream & | s, |
int | indent = 0 |
||
) | const |
Prints on s
the tree rooted in *this
.
s | The output stream. |
indent | The amount of indentation. |
Definition at line 3811 of file PIP_Tree.cc.
References get_owner(), Parma_Polyhedra_Library::PIP_Problem::parameter_space_dimensions(), parent(), Parma_Polyhedra_Library::PIP_Solution_Node::print_tree(), and Parma_Polyhedra_Library::PIP_Problem::space_dimension().
Referenced by Parma_Polyhedra_Library::IO_Operators::operator<<().
|
protectedpure virtual |
Prints on s
the tree rooted in *this
.
s | The output stream. |
indent | The amount of indentation. |
pip_dim_is_param | A vector of Boolean flags telling which PIP problem dimensions are problem parameters. The size of the vector is equal to the PIP problem internal space dimension (i.e., no artificial parameters). |
first_art_dim | The first space dimension corresponding to an artificial parameter that was created in this node (if any). |
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
Definition at line 3831 of file PIP_Tree.cc.
References art_parameter_begin(), art_parameter_end(), Parma_Polyhedra_Library::Constraint_System::begin(), constraints_, Parma_Polyhedra_Library::Constraint_System::empty(), Parma_Polyhedra_Library::Constraint_System::end(), and indent_and_print().
Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::print_tree(), and Parma_Polyhedra_Library::PIP_Decision_Node::print_tree().
|
protectedpure virtual |
Sets the pointer to the PIP_Problem owning object.
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
Referenced by Parma_Polyhedra_Library::PIP_Problem::PIP_Problem(), and Parma_Polyhedra_Library::PIP_Decision_Node::set_owner().
|
inlineprotected |
Set this node's parent to *p
.
Definition at line 56 of file PIP_Tree_inlines.hh.
References parent_.
Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::PIP_Decision_Node(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().
|
protectedpure virtual |
Executes a parametric simplex on the tableau, under specified context.
pip | The PIP_Problem object containing this node. |
check_feasible_context | Whether the resolution process should (re-)check feasibility of context (since the initial context may have been modified). |
context | The context, being a set of constraints on the parameters. |
params | The local parameter set, including parent's artificial parameters. |
space_dim | The space dimension of parent, including artificial parameters. |
indent_level | The indentation level (for debugging output only). |
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
Referenced by Parma_Polyhedra_Library::PIP_Problem::solve(), and Parma_Polyhedra_Library::PIP_Solution_Node::solve().
|
pure virtual |
Returns the total size in bytes of the memory occupied by *this
.
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
|
protectedpure virtual |
Populates the parametric simplex tableau using external data.
pip | The PIP_Problem object containing this node. |
external_space_dim | The number of all problem variables and problem parameters (excluding artificial parameters). |
first_pending_constraint | The first element in input_cs to be added to the tableau, which already contains the previous elements. |
input_cs | All the constraints of the PIP problem. |
parameters | The set of indices of the problem parameters. |
Implemented in Parma_Polyhedra_Library::PIP_Decision_Node, and Parma_Polyhedra_Library::PIP_Solution_Node.
Referenced by Parma_Polyhedra_Library::PIP_Problem::solve().
|
related |
Output operator: prints the solution tree rooted in x
.
Definition at line 902 of file PIP_Tree.cc.
|
friend |
Definition at line 147 of file PIP_Tree_defs.hh.
Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::ascii_load(), Parma_Polyhedra_Library::PIP_Decision_Node::clone(), and Parma_Polyhedra_Library::PIP_Solution_Node::solve().
|
friend |
Definition at line 146 of file PIP_Tree_defs.hh.
|
friend |
Definition at line 148 of file PIP_Tree_defs.hh.
|
protected |
The local sequence of expressions for local artificial parameters.
Definition at line 160 of file PIP_Tree_defs.hh.
Referenced by art_parameter_begin(), art_parameter_count(), art_parameter_end(), ascii_dump(), ascii_load(), external_memory_in_bytes(), Parma_Polyhedra_Library::PIP_Solution_Node::generate_cut(), parent_merge(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().
|
protected |
The local system of parameter constraints.
Definition at line 157 of file PIP_Tree_defs.hh.
Referenced by add_constraint(), ascii_dump(), ascii_load(), constraints(), external_memory_in_bytes(), OK(), Parma_Polyhedra_Library::PIP_Decision_Node::OK(), print_tree(), Parma_Polyhedra_Library::PIP_Solution_Node::print_tree(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().
|
protected |
A pointer to the PIP_Problem object owning this node.
Definition at line 151 of file PIP_Tree_defs.hh.
Referenced by get_owner(), Parma_Polyhedra_Library::PIP_Solution_Node::set_owner(), and Parma_Polyhedra_Library::PIP_Decision_Node::set_owner().
|
protected |
A pointer to the parent of *this
, null if *this
is the root.
Definition at line 154 of file PIP_Tree_defs.hh.
Referenced by parent(), parent_merge(), and set_parent().