Parma_Polyhedra_Library::PIP_Tree_Node Class Reference

A node of the PIP solution tree. More...

#include <PIP_Tree.defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::PIP_Tree_Node:
Inheritance graph
[legend]
Collaboration diagram for Parma_Polyhedra_Library::PIP_Tree_Node:
Collaboration graph
[legend]

List of all members.

Classes

class  Artificial_Parameter
 Artificial parameters in PIP solution trees. More...

Public Types

typedef std::vector
< Artificial_Parameter
Artificial_Parameter_Sequence
 A type alias for a sequence of Artificial_Parameter's.

Public Member Functions

virtual PIP_Tree_Nodeclone () const =0
 Returns a pointer to a dynamically-allocated copy of *this.
virtual ~PIP_Tree_Node ()
 Destructor.
virtual bool OK () const
 Returns true if and only if *this is well formed.
virtual const PIP_Solution_Nodeas_solution () const
 Returns this if *this is a solution node, 0 otherwise.
virtual const PIP_Decision_Nodeas_decision () const
 Returns this if *this is a decision node, 0 otherwise.
const Constraint_Systemconstraints () const
 Returns the system of parameter constraints controlling *this.
Artificial_Parameter_Sequence::const_iterator art_parameter_begin () const
 Returns a const_iterator to the beginning of local artificial parameters.
Artificial_Parameter_Sequence::const_iterator art_parameter_end () const
 Returns a const_iterator to the end of local artificial parameters.
dimension_type art_parameter_count () const
 Returns the number of local artificial parameters.
void print (std::ostream &s, unsigned indent=0) const
 Prints on s the tree rooted in *this.
void ascii_dump (std::ostream &s) const
 Dumps to s an ASCII representation of *this.
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.
virtual memory_size_type total_memory_in_bytes () const =0
 Returns the total size in bytes of the memory occupied by *this.
virtual memory_size_type external_memory_in_bytes () const =0
 Returns the size in bytes of the memory managed by *this.

Protected Types

typedef std::vector< ConstraintConstraint_Sequence
 A type alias for a sequence of constraints.

Protected Member Functions

 PIP_Tree_Node (const PIP_Problem *owner)
 Constructor: builds a node owned by *owner.
 PIP_Tree_Node (const PIP_Tree_Node &y)
 Copy constructor.
const PIP_Problemget_owner () const
 Returns a pointer to the PIP_Problem owning object.
virtual void set_owner (const PIP_Problem *owner)=0
 Sets the pointer to the PIP_Problem owning object.
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 is owned by *pip.
const PIP_Decision_Nodeparent () const
 Returns a pointer to this node's parent.
void set_parent (const PIP_Decision_Node *p)
 Set this node's parent to *p.
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 &parameters)=0
 Populates the parametric simplex tableau using external data.
virtual PIP_Tree_Nodesolve (const PIP_Problem &pip, bool check_feasible_context, const Matrix &context, const Variables_Set &params, dimension_type space_dim, unsigned indent_level)=0
 Executes a parametric simplex on the tableau, under specified context.
void add_constraint (const Row &x, const Variables_Set &parameters)
 Inserts a new parametric constraint in internal Row format.
void parent_merge ()
 Merges parent's artificial parameters into *this.
virtual void print_tree (std::ostream &s, unsigned indent, const std::vector< bool > &pip_dim_is_param, dimension_type first_art_dim) const
 Prints on s the tree rooted in *this.

Static Protected Member Functions

static void indent_and_print (std::ostream &s, unsigned indent, const char *str)
 A helper function used when printing PIP trees.
static bool compatibility_check (Matrix &s)
 Checks whether a context matrix is satisfiable.
static bool compatibility_check (const Matrix &context, const Row &row)
 Helper method: checks for satisfiability of the restricted context obtained by adding row to context.

Protected Attributes

const PIP_Problemowner_
 A pointer to the PIP_Problem object owning this node.
const PIP_Decision_Nodeparent_
 A pointer to the parent of *this, null if *this is the root.
Constraint_System constraints_
 The local system of parameter constraints.
Artificial_Parameter_Sequence artificial_parameters
 The local sequence of expressions for local artificial parameters.

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.

Detailed Description

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 47 of file PIP_Tree.defs.hh.


Member Typedef Documentation

A type alias for a sequence of Artificial_Parameter's.

Definition at line 92 of file PIP_Tree.defs.hh.

A type alias for a sequence of constraints.

Definition at line 133 of file PIP_Tree.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::PIP_Tree_Node::PIP_Tree_Node ( const PIP_Problem owner  )  [explicit, protected]

Constructor: builds a node owned by *owner.

Definition at line 355 of file PIP_Tree.cc.

00356   : owner_(owner),
00357     parent_(0),
00358     constraints_(),
00359     artificial_parameters() {
00360 }

Parma_Polyhedra_Library::PIP_Tree_Node::PIP_Tree_Node ( const PIP_Tree_Node y  )  [protected]

Copy constructor.

Definition at line 362 of file PIP_Tree.cc.

00363   : owner_(y.owner_),
00364     parent_(0), // NOTE: parent is not copied.
00365     constraints_(y.constraints_),
00366     artificial_parameters(y.artificial_parameters) {
00367 }

Parma_Polyhedra_Library::PIP_Tree_Node::~PIP_Tree_Node (  )  [inline, virtual]

Destructor.

Definition at line 56 of file PIP_Tree.inlines.hh.

00056                               {
00057 }


Member Function Documentation

void Parma_Polyhedra_Library::PIP_Tree_Node::add_constraint ( const Row x,
const Variables_Set parameters 
) [protected]

Inserts a new parametric constraint in internal Row format.

Definition at line 663 of file PIP_Tree.cc.

References Parma_Polyhedra_Library::add_mul_assign(), Parma_Polyhedra_Library::Row::size(), WEIGHT_ADD_MUL, and WEIGHT_BEGIN.

Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::solve().

00663                                                                 {
00664   const dimension_type num_params = parameters.size();
00665   PPL_ASSERT(num_params + 1 == row.size());
00666 
00667   // Compute the expression for the parameter constraint.
00668   Linear_Expression expr = Linear_Expression(row[0]);
00669   // NOTE: iterating downward on parameters to avoid reallocations.
00670   Variables_Set::const_reverse_iterator p_j = parameters.rbegin();
00671   // NOTE: index j spans [1..num_params] downwards.
00672   WEIGHT_BEGIN();
00673   for (dimension_type j = num_params; j > 0; --j) {
00674     add_mul_assign(expr, row[j], Variable(*p_j));
00675     // Move to previous parameter.
00676     ++p_j;
00677   }
00678   WEIGHT_ADD_MUL(1, num_params);
00679 
00680   // Add the parameter constraint.
00681   constraints_.insert(expr >= 0);
00682 }

PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator Parma_Polyhedra_Library::PIP_Tree_Node::art_parameter_begin (  )  const [inline]

Returns a const_iterator to the beginning of local artificial parameters.

Definition at line 80 of file PIP_Tree.inlines.hh.

References artificial_parameters.

Referenced by external_memory_in_bytes(), parent_merge(), and print_tree().

00080                                          {
00081   return artificial_parameters.begin();
00082 }

dimension_type Parma_Polyhedra_Library::PIP_Tree_Node::art_parameter_count (  )  const [inline]

Returns the number of local artificial parameters.

Definition at line 90 of file PIP_Tree.inlines.hh.

References artificial_parameters.

Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::print_tree().

00090                                          {
00091   return artificial_parameters.size();
00092 }

PIP_Tree_Node::Artificial_Parameter_Sequence::const_iterator Parma_Polyhedra_Library::PIP_Tree_Node::art_parameter_end (  )  const [inline]

Returns a const_iterator to the end of local artificial parameters.

Definition at line 85 of file PIP_Tree.inlines.hh.

References artificial_parameters.

Referenced by external_memory_in_bytes(), parent_merge(), and print_tree().

00085                                        {
00086   return artificial_parameters.end();
00087 }

const PIP_Decision_Node * Parma_Polyhedra_Library::PIP_Tree_Node::as_decision (  )  const [virtual]

Returns this if *this is a decision node, 0 otherwise.

Reimplemented in Parma_Polyhedra_Library::PIP_Decision_Node.

Definition at line 594 of file PIP_Tree.cc.

Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::ascii_dump(), and Parma_Polyhedra_Library::PIP_Problem::ascii_dump().

00594                                  {
00595   return 0;
00596 }

const PIP_Solution_Node * Parma_Polyhedra_Library::PIP_Tree_Node::as_solution (  )  const [virtual]

Returns this if *this is a solution node, 0 otherwise.

Reimplemented in Parma_Polyhedra_Library::PIP_Solution_Node.

Definition at line 589 of file PIP_Tree.cc.

Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::ascii_dump(), and Parma_Polyhedra_Library::PIP_Problem::ascii_dump().

00589                                  {
00590   return 0;
00591 }

void Parma_Polyhedra_Library::PIP_Tree_Node::ascii_dump ( std::ostream &  s  )  const

Dumps to s an ASCII representation of *this.

Reimplemented in Parma_Polyhedra_Library::PIP_Solution_Node, and Parma_Polyhedra_Library::PIP_Decision_Node.

Definition at line 1186 of file PIP_Tree.cc.

References artificial_parameters, Parma_Polyhedra_Library::Constraint_System::ascii_dump(), and constraints_.

Referenced by OK().

01186                                              {
01187   s << "constraints_\n";
01188   constraints_.ascii_dump(s);
01189   dimension_type artificial_parameters_size = artificial_parameters.size();
01190   s << "\nartificial_parameters( " << artificial_parameters_size << " )\n";
01191   for (dimension_type i = 0; i < artificial_parameters_size; ++i)
01192     artificial_parameters[i].ascii_dump(s);
01193 }

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.

Reimplemented in Parma_Polyhedra_Library::PIP_Solution_Node, and Parma_Polyhedra_Library::PIP_Decision_Node.

Definition at line 1196 of file PIP_Tree.cc.

References artificial_parameters, Parma_Polyhedra_Library::PIP_Tree_Node::Artificial_Parameter::ascii_load(), Parma_Polyhedra_Library::Constraint_System::ascii_load(), and constraints_.

Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::ascii_load(), and Parma_Polyhedra_Library::PIP_Decision_Node::ascii_load().

01196                                        {
01197   std::string str;
01198   if (!(s >> str) || str != "constraints_")
01199     return false;
01200   constraints_.ascii_load(s);
01201 
01202   if (!(s >> str) || str != "artificial_parameters(")
01203     return false;
01204   dimension_type artificial_parameters_size;
01205   if (!(s >> artificial_parameters_size))
01206     return false;
01207   if (!(s >> str) || str != ")")
01208     return false;
01209   Artificial_Parameter ap;
01210   for (dimension_type i = 0; i < artificial_parameters_size; ++i) {
01211     if (!ap.ascii_load(s))
01212       return false;
01213     artificial_parameters.push_back(ap);
01214   }
01215 
01216   // Note: do not assert OK() here.
01217   // The node invariants should be checked on derived nodes.
01218   return true;
01219 }

virtual bool Parma_Polyhedra_Library::PIP_Tree_Node::check_ownership ( const PIP_Problem owner  )  const [protected, pure virtual]

Returns true if and only if all the nodes in the subtree rooted in *this is owned by *pip.

Implemented in Parma_Polyhedra_Library::PIP_Solution_Node, and Parma_Polyhedra_Library::PIP_Decision_Node.

Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::check_ownership(), and Parma_Polyhedra_Library::PIP_Problem::OK().

virtual PIP_Tree_Node* Parma_Polyhedra_Library::PIP_Tree_Node::clone (  )  const [pure virtual]
bool Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check ( const Matrix context,
const Row row 
) [static, protected]

Helper method: checks for satisfiability of the restricted context obtained by adding row to context.

Definition at line 1492 of file PIP_Tree.cc.

References Parma_Polyhedra_Library::Matrix::add_row(), and compatibility_check().

01492                                                                         {
01493   // CHECKME: do `context' and `row' have compatible (row) capacity?
01494   Matrix s(context);
01495   s.add_row(row);
01496   return compatibility_check(s);
01497 }

bool Parma_Polyhedra_Library::PIP_Tree_Node::compatibility_check ( Matrix s  )  [static, protected]

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 1500 of file PIP_Tree.cc.

References Parma_Polyhedra_Library::Matrix::add_zero_rows(), Parma_Polyhedra_Library::Matrix::erase_to_end(), Parma_Polyhedra_Library::exact_div_assign(), Parma_Polyhedra_Library::gcd_assign(), Parma_Polyhedra_Library::maybe_abandon(), Parma_Polyhedra_Library::not_a_dimension(), Parma_Polyhedra_Library::Matrix::num_columns(), Parma_Polyhedra_Library::Matrix::num_rows(), Parma_Polyhedra_Library::Matrix::OK(), PPL_DIRTY_TEMP_COEFFICIENT, Parma_Polyhedra_Library::swap(), WEIGHT_ADD, WEIGHT_ADD_MUL, and WEIGHT_BEGIN.

Referenced by compatibility_check(), Parma_Polyhedra_Library::PIP_Solution_Node::solve(), Parma_Polyhedra_Library::PIP_Decision_Node::solve(), and Parma_Polyhedra_Library::PIP_Problem::solve().

01500                                             {
01501   PPL_ASSERT(s.OK());
01502   // Note: num_rows may increase.
01503   dimension_type num_rows = s.num_rows();
01504   const dimension_type num_cols = s.num_columns();
01505   const dimension_type num_vars = num_cols - 1;
01506 
01507   std::vector<Coefficient> scaling(num_rows, 1);
01508   std::vector<bool> basis;
01509   basis.reserve(num_vars + num_rows);
01510   std::vector<dimension_type> mapping;
01511   mapping.reserve(num_vars + num_rows);
01512   std::vector<dimension_type> var_row;
01513   var_row.reserve(num_rows);
01514   std::vector<dimension_type> var_column;
01515   var_column.reserve(num_cols);
01516 
01517   // Column 0 is the constant term, not a variable
01518   var_column.push_back(not_a_dimension());
01519   for (dimension_type j = 1; j <= num_vars; ++j) {
01520     basis.push_back(true);
01521     mapping.push_back(j);
01522     var_column.push_back(j-1);
01523   }
01524   for (dimension_type i = 0; i < num_rows; ++i) {
01525     basis.push_back(false);
01526     mapping.push_back(i);
01527     var_row.push_back(i+num_vars);
01528   }
01529 
01530   // Scaling factor (i.e., denominator) for pivot coefficients.
01531   PPL_DIRTY_TEMP_COEFFICIENT(pivot_den);
01532   // Allocate once and for all: short life temporaries.
01533   PPL_DIRTY_TEMP_COEFFICIENT(product);
01534   PPL_DIRTY_TEMP_COEFFICIENT(gcd);
01535   PPL_DIRTY_TEMP_COEFFICIENT(scale_factor);
01536 
01537   // Perform simplex pivots on the context
01538   // until we find an empty solution or an optimum.
01539   while (true) {
01540     // Check if the client has requested abandoning all expensive
01541     // computations. If so, the exception specified by the client
01542     // is thrown now.
01543     maybe_abandon();
01544 
01545     dimension_type pi = num_rows; // pi is the pivot's row index.
01546     dimension_type pj = 0;        // pj is the pivot's column index.
01547 
01548     // Look for a negative RHS (i.e., constant term, stored in column 0),
01549     // maximizing pivot column.
01550     for (dimension_type i = 0; i < num_rows; ++i) {
01551       const Row& s_i = s[i];
01552       if (s_i[0] < 0) {
01553         dimension_type j;
01554         if (!find_lexico_minimum_column(s, mapping, basis, s_i, 1, j)) {
01555           // No positive pivot candidate: unfeasible problem.
01556           return false;
01557         }
01558         // Update pair (pi, pj) if they are still unset or
01559         // if the challenger pair (i, j) is better in the ordering.
01560         if (pj == 0
01561             || column_lower(s, mapping, basis,
01562                             s[pi], pj, s_i, j,
01563                             s[pi][0], s_i[0])) {
01564           pi = i;
01565           pj = j;
01566         }
01567       }
01568     }
01569 
01570     if (pj == 0) {
01571       // No negative RHS: fractional optimum found.
01572       // If it is integer, then the test is successful.
01573       // Otherwise, generate a new cut.
01574       bool all_integer_vars = true;
01575       // NOTE: iterating downwards would be correct, but it would change
01576       // the ordering of cut generation.
01577       WEIGHT_BEGIN();
01578       for (dimension_type i = 0; i < num_vars; ++i) {
01579         if (basis[i])
01580           // Basic variable = 0, hence integer.
01581           continue;
01582         // Not a basic variable.
01583         WEIGHT_ADD(1);
01584         const dimension_type mi = mapping[i];
01585         const Coefficient& den = scaling[mi];
01586         if (s[mi][0] % den == 0)
01587           continue;
01588         // Here constant term is not integer.
01589         all_integer_vars = false;
01590         // Generate a new cut.
01591         var_row.push_back(mapping.size());
01592         basis.push_back(false);
01593         mapping.push_back(num_rows);
01594         s.add_zero_rows(1, Row::Flags());
01595         Row& cut = s[num_rows];
01596         ++num_rows;
01597         const Row& s_mi = s[mi];
01598         for (dimension_type j = num_cols; j-- > 0; )
01599           pos_mod_assign(cut[j], s_mi[j], den);
01600         WEIGHT_ADD_MUL(1, num_cols);
01601         cut[0] -= den;
01602         scaling.push_back(den);
01603       }
01604       // Check if an integer solution was found.
01605       if (all_integer_vars)
01606         return true;
01607       else
01608         continue;
01609     }
01610 
01611     // Here we have a positive s[pi][pj] pivot.
01612 
01613     // Normalize the tableau before pivoting.
01614     for (dimension_type i = num_rows; i-- > 0; )
01615       row_normalize(s[i], scaling[i]);
01616 
01617     // Update basis.
01618     {
01619       const dimension_type var_pi = var_row[pi];
01620       const dimension_type var_pj = var_column[pj];
01621       var_row[pi] = var_pj;
01622       var_column[pj] = var_pi;
01623       basis[var_pi] = true;
01624       basis[var_pj] = false;
01625       mapping[var_pi] = pj;
01626       mapping[var_pj] = pi;
01627     }
01628 
01629     // Create an identity row corresponding to basic variable pj.
01630     s.add_zero_rows(1, Row::Flags());
01631     Row& pivot = s[num_rows];
01632     pivot[pj] = 1;
01633 
01634     // Swap identity row with the pivot row previously found.
01635     std::swap(pivot, s[pi]);
01636     // Save original pivot scaling factor in a temporary,
01637     // then reset scaling factor for identity row.
01638     pivot_den = scaling[pi];
01639     scaling[pi] = 1;
01640 
01641     // Perform a pivot operation on the matrix.
01642     const Coefficient& pivot_pj = pivot[pj];
01643     for (dimension_type j = num_cols; j-- > 0; ) {
01644       if (j == pj)
01645         continue;
01646       const Coefficient& pivot_j = pivot[j];
01647       // Do nothing if the j-th pivot element is zero.
01648       if (pivot_j == 0)
01649         continue;
01650       WEIGHT_BEGIN();
01651       for (dimension_type i = num_rows; i-- > 0; ) {
01652         Row& s_i = s[i];
01653         product = s_i[pj] * pivot_j;
01654         if (product % pivot_pj != 0) {
01655           WEIGHT_ADD(4);
01656           // Must scale row s_i to stay in integer case.
01657           gcd_assign(gcd, product, pivot_pj);
01658           exact_div_assign(scale_factor, pivot_pj, gcd);
01659           for (dimension_type k = num_cols; k-- > 0; )
01660             s_i[k] *= scale_factor;
01661           WEIGHT_ADD_MUL(1, num_cols);
01662           product *= scale_factor;
01663           scaling[i] *= scale_factor;
01664         }
01665         PPL_ASSERT(product % pivot_pj == 0);
01666         exact_div_assign(product, product, pivot_pj);
01667         s_i[j] -= product;
01668         WEIGHT_ADD(4);
01669       }
01670     }
01671     // Update column only if pivot coordinate != 1.
01672     if (pivot_pj != pivot_den) {
01673       WEIGHT_BEGIN();
01674       for (dimension_type i = num_rows; i-- > 0; ) {
01675         Row& s_i = s[i];
01676         Coefficient& s_i_pj = s_i[pj];
01677         product = s_i_pj * pivot_den;
01678         if (product % pivot_pj != 0) {
01679           WEIGHT_ADD(4);
01680           // As above, perform row scaling.
01681           gcd_assign(gcd, product, pivot_pj);
01682           exact_div_assign(scale_factor, pivot_pj, gcd);
01683           for (dimension_type k = num_cols; k-- > 0; )
01684             s_i[k] *= scale_factor;
01685           WEIGHT_ADD_MUL(1, num_cols);
01686           product *= scale_factor;
01687           scaling[i] *= scale_factor;
01688         }
01689         PPL_ASSERT(product % pivot_pj == 0);
01690         exact_div_assign(s_i_pj, product, pivot_pj);
01691         WEIGHT_ADD(3);
01692       }
01693     }
01694     // Drop pivot to restore proper matrix size.
01695     s.erase_to_end(num_rows);
01696   }
01697 
01698   // This point should be unreachable.
01699   throw std::runtime_error("PPL internal error");
01700 }

const Constraint_System & Parma_Polyhedra_Library::PIP_Tree_Node::constraints (  )  const [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 75 of file PIP_Tree.inlines.hh.

References constraints_.

00075                                  {
00076   return constraints_;
00077 }

memory_size_type Parma_Polyhedra_Library::PIP_Tree_Node::external_memory_in_bytes (  )  const [pure virtual]

Returns the size in bytes of the memory managed by *this.

Implemented in Parma_Polyhedra_Library::PIP_Solution_Node, and Parma_Polyhedra_Library::PIP_Decision_Node.

Definition at line 2850 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().

02850                                               {
02851   memory_size_type n = constraints_.external_memory_in_bytes();
02852   // Adding the external memory for `artificial_parameters'.
02853   n += artificial_parameters.capacity() * sizeof(Artificial_Parameter);
02854   for (Artificial_Parameter_Sequence::const_iterator
02855          ap = art_parameter_begin(),
02856          ap_end = art_parameter_end(); ap != ap_end; ++ap)
02857     n += (ap->external_memory_in_bytes());
02858 
02859   return n;
02860 }

const PIP_Problem * Parma_Polyhedra_Library::PIP_Tree_Node::get_owner (  )  const [inline, protected]
void Parma_Polyhedra_Library::PIP_Tree_Node::indent_and_print ( std::ostream &  s,
unsigned  indent,
const char *  str 
) [static, protected]
bool Parma_Polyhedra_Library::PIP_Tree_Node::OK (  )  const [virtual]

Returns true if and only if *this is well formed.

Reimplemented in Parma_Polyhedra_Library::PIP_Solution_Node, and Parma_Polyhedra_Library::PIP_Decision_Node.

Definition at line 637 of file PIP_Tree.cc.

References ascii_dump(), Parma_Polyhedra_Library::Constraint_System::begin(), constraints_, and Parma_Polyhedra_Library::Constraint_System::end().

Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::OK(), Parma_Polyhedra_Library::PIP_Solution_Node::OK(), Parma_Polyhedra_Library::PIP_Problem::OK(), parent_merge(), and Parma_Polyhedra_Library::PIP_Decision_Node::solve().

00637                         {
00638 #ifndef NDEBUG
00639   using std::endl;
00640   using std::cerr;
00641 #endif
00642 
00643   const Constraint_System::const_iterator begin = constraints_.begin();
00644   const Constraint_System::const_iterator end = constraints_.end();
00645 
00646   // Parameter constraint system should contain no strict inequalities.
00647   for (Constraint_System::const_iterator ci = begin; ci != end; ++ci)
00648     if (ci->is_strict_inequality()) {
00649 #ifndef NDEBUG
00650       cerr << "The feasible region of the PIP_Problem parameter context"
00651            << "is defined by a constraint system containing strict "
00652            << "inequalities."
00653            << endl;
00654       ascii_dump(cerr);
00655 #endif
00656       return false;
00657     }
00658   return true;
00659 }

const PIP_Decision_Node * Parma_Polyhedra_Library::PIP_Tree_Node::parent (  )  const [inline, protected]

Returns a pointer to this node's parent.

Definition at line 65 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().

00065                             {
00066   return parent_;
00067 }

void Parma_Polyhedra_Library::PIP_Tree_Node::parent_merge (  )  [protected]

Merges parent's artificial parameters into *this.

Definition at line 685 of file PIP_Tree.cc.

References art_parameter_begin(), art_parameter_end(), artificial_parameters, OK(), parent(), and parent_.

Referenced by Parma_Polyhedra_Library::PIP_Decision_Node::solve().

00685                             {
00686   const PIP_Decision_Node& parent = *parent_;
00687 
00688   // Merge the parent's artificial parameters.
00689   artificial_parameters.insert(artificial_parameters.begin(),
00690                                parent.art_parameter_begin(),
00691                                parent.art_parameter_end());
00692 
00693   PPL_ASSERT(OK());
00694 }

void Parma_Polyhedra_Library::PIP_Tree_Node::print ( std::ostream &  s,
unsigned  indent = 0 
) const

Prints on s the tree rooted in *this.

Parameters:
s The output stream.
indent The amount of indentation.

Definition at line 2915 of file PIP_Tree.cc.

References get_owner(), Parma_Polyhedra_Library::PIP_Problem::parameter_space_dimensions(), parent(), print_tree(), and Parma_Polyhedra_Library::PIP_Problem::space_dimension().

Referenced by Parma_Polyhedra_Library::IO_Operators::operator<<(), and Parma_Polyhedra_Library::PIP_Problem::print_solution().

02915                                                          {
02916   const dimension_type pip_space_dim = get_owner()->space_dimension();
02917   const Variables_Set& pip_params = get_owner()->parameter_space_dimensions();
02918 
02919   std::vector<bool> pip_dim_is_param(pip_space_dim);
02920   for (Variables_Set::const_iterator p = pip_params.begin(),
02921          p_end = pip_params.end(); p != p_end; ++p)
02922     pip_dim_is_param[*p] = true;
02923 
02924   dimension_type first_art_dim = pip_space_dim;
02925   for (const PIP_Tree_Node* node = parent(); node != 0; node = node->parent())
02926     first_art_dim += node->art_parameter_count();
02927 
02928   print_tree(s, indent, pip_dim_is_param, first_art_dim);
02929 }

void Parma_Polyhedra_Library::PIP_Tree_Node::print_tree ( std::ostream &  s,
unsigned  indent,
const std::vector< bool > &  pip_dim_is_param,
dimension_type  first_art_dim 
) const [protected, virtual]

Prints on s the tree rooted in *this.

Parameters:
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).

Reimplemented in Parma_Polyhedra_Library::PIP_Solution_Node, and Parma_Polyhedra_Library::PIP_Decision_Node.

Definition at line 2932 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 print(), and Parma_Polyhedra_Library::PIP_Decision_Node::print_tree().

02934                                                               {
02935   used(pip_dim_is_param);
02936 
02937   using namespace IO_Operators;
02938 
02939   // Print artificial parameters.
02940   for (Artificial_Parameter_Sequence::const_iterator
02941          api = art_parameter_begin(),
02942          api_end = art_parameter_end(); api != api_end; ++api) {
02943     indent_and_print(s, indent, "Parameter ");
02944     s << Variable(first_art_dim) << " = " << *api << "\n";
02945     ++first_art_dim;
02946   }
02947 
02948   // Print constraints, if any.
02949   if (!constraints_.empty()) {
02950     indent_and_print(s, indent, "if ");
02951 
02952     Constraint_System::const_iterator ci = constraints_.begin();
02953     Constraint_System::const_iterator ci_end = constraints_.end();
02954     PPL_ASSERT(ci != ci_end);
02955     s << *ci;
02956     for (++ci; ci != ci_end; ++ci)
02957       s << " and " << *ci;
02958 
02959     s << " then\n";
02960   }
02961 }

virtual void Parma_Polyhedra_Library::PIP_Tree_Node::set_owner ( const PIP_Problem owner  )  [protected, pure virtual]
void Parma_Polyhedra_Library::PIP_Tree_Node::set_parent ( const PIP_Decision_Node p  )  [inline, protected]

Set this node's parent to *p.

Definition at line 60 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().

00060                                                     {
00061   parent_ = p;
00062 }

virtual PIP_Tree_Node* Parma_Polyhedra_Library::PIP_Tree_Node::solve ( const PIP_Problem pip,
bool  check_feasible_context,
const Matrix context,
const Variables_Set params,
dimension_type  space_dim,
unsigned  indent_level 
) [protected, pure virtual]

Executes a parametric simplex on the tableau, under specified context.

Returns:
The root of the PIP tree solution, or 0 if unfeasible.
Parameters:
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_Solution_Node, and Parma_Polyhedra_Library::PIP_Decision_Node.

Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::solve(), Parma_Polyhedra_Library::PIP_Decision_Node::solve(), and Parma_Polyhedra_Library::PIP_Problem::solve().

virtual memory_size_type Parma_Polyhedra_Library::PIP_Tree_Node::total_memory_in_bytes (  )  const [pure virtual]
virtual void Parma_Polyhedra_Library::PIP_Tree_Node::update_tableau ( const PIP_Problem pip,
dimension_type  external_space_dim,
dimension_type  first_pending_constraint,
const Constraint_Sequence input_cs,
const Variables_Set parameters 
) [protected, pure virtual]

Populates the parametric simplex tableau using external data.

Parameters:
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_Solution_Node, and Parma_Polyhedra_Library::PIP_Decision_Node.

Referenced by Parma_Polyhedra_Library::PIP_Problem::solve(), and Parma_Polyhedra_Library::PIP_Decision_Node::update_tableau().


Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  os,
const PIP_Tree_Node x 
) [related]

Output operator: prints the solution tree rooted in x.

Definition at line 341 of file PIP_Tree.cc.

00341                                                    {
00342   x.print(os);
00343   return os;
00344 }

friend class PIP_Decision_Node [friend]

Definition at line 138 of file PIP_Tree.defs.hh.

Referenced by Parma_Polyhedra_Library::PIP_Solution_Node::solve().

friend class PIP_Problem [friend]

Definition at line 137 of file PIP_Tree.defs.hh.

friend class PIP_Solution_Node [friend]

Reimplemented in Parma_Polyhedra_Library::PIP_Decision_Node.

Definition at line 139 of file PIP_Tree.defs.hh.


Member Data Documentation

A pointer to the parent of *this, null if *this is the root.

Definition at line 145 of file PIP_Tree.defs.hh.

Referenced by parent(), parent_merge(), and set_parent().


The documentation for this class was generated from the following files:
Generated on Sun Feb 27 16:20:32 2011 for PPL by  doxygen 1.6.3