[PPL-devel] [GIT] ppl/ppl(pip): Redefined and implemented the tree node constructors.

François Galea francois.galea at uvsq.fr
Wed Sep 16 15:31:39 CEST 2009


Module: ppl/ppl
Branch: pip
Commit: c93acf108e683d72dc4aef9f6e93d7d7b29b206a
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=c93acf108e683d72dc4aef9f6e93d7d7b29b206a

Author: François Galea <francois.galea at uvsq.fr>
Date:   Wed Sep 16 15:15:28 2009 +0200

Redefined and implemented the tree node constructors.

---

 src/PIP_Tree.cc      |   40 +++++++++++++++++++++++++++++++++++++
 src/PIP_Tree.defs.hh |   53 +++++++++++++++++++++++++------------------------
 2 files changed, 67 insertions(+), 26 deletions(-)

diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index c9f576a..30e4080 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -64,6 +64,13 @@ negate_assign(Row& x, const Row& y) {
 
 } // namespace
 
+PIP_Tree_Node::PIP_Tree_Node()
+  : constraints_() {
+}
+
+PIP_Tree_Node::PIP_Tree_Node(const PIP_Tree_Node &x)
+  : constraints_(x.constraints_) {
+}
 
 PIP_Decision_Node::~PIP_Decision_Node() {
   delete true_child;
@@ -73,6 +80,39 @@ PIP_Decision_Node::~PIP_Decision_Node() {
 PIP_Solution_Node::~PIP_Solution_Node() {
 }
 
+PIP_Solution_Node::PIP_Solution_Node()
+  : PIP_Tree_Node(),
+    tableau(),
+    basis(),
+    mapping(),
+    sign() {
+}
+
+PIP_Solution_Node::PIP_Solution_Node(const PIP_Solution_Node &x)
+  : PIP_Tree_Node(x),
+    tableau(x.tableau),
+    basis(x.basis),
+    mapping(x.mapping),
+    sign(x.sign) {
+}
+
+PIP_Solution_Node::PIP_Solution_Node(const PIP_Solution_Node &x,
+                                     bool empty_constraints)
+  : PIP_Tree_Node(),
+    tableau(x.tableau),
+    basis(x.basis),
+    mapping(x.mapping),
+    sign(x.sign) {
+  if (!empty_constraints)
+    constraints_ = x.constraints_;
+}
+
+PIP_Decision_Node::PIP_Decision_Node(PIP_Tree_Node* fcp, PIP_Tree_Node* tcp)
+  : PIP_Tree_Node(),
+    true_child(tcp),
+    false_child(fcp) {
+}
+
 const PIP_Solution_Node*
 PIP_Tree_Node::as_solution() const {
   return 0;
diff --git a/src/PIP_Tree.defs.hh b/src/PIP_Tree.defs.hh
index e88aa0f..72c6fc6 100644
--- a/src/PIP_Tree.defs.hh
+++ b/src/PIP_Tree.defs.hh
@@ -71,6 +71,12 @@ public:
   const Constraint_System& constraints() const;
 
 protected:
+  //! Default constructor.
+  PIP_Tree_Node();
+
+  //! Copy constructor.
+  PIP_Tree_Node(const PIP_Tree_Node &x);
+
   //! A type alias for a sequence of constraints.
   typedef std::vector<Constraint> Constraint_Sequence;
 
@@ -78,6 +84,7 @@ protected:
   // constructor and methods.
   friend class PIP_Problem;
   friend class PIP_Decision_Node;
+  friend class PIP_Solution_Node;
 
   //! The local system of parameter constraints.
   Constraint_System constraints_;
@@ -127,6 +134,9 @@ protected:
 //! A tree node representing part of the space of solutions.
 class PIP_Solution_Node : public PIP_Tree_Node {
 public:
+  //! Default constructor.
+  PIP_Solution_Node();
+
   //! Destructor.
   ~PIP_Solution_Node();
 
@@ -272,6 +282,12 @@ private:
   static bool compatibility_check(const Matrix &ctx, const Row &cnst);
 
 protected:
+  //! Copy constructor.
+  PIP_Solution_Node(const PIP_Solution_Node &x);
+
+  //! Copy constructor, allowing not to copy the constraint system.
+  PIP_Solution_Node(const PIP_Solution_Node &x, bool empty_constraints);
+
   /*! \brief
     Populates the parametric simplex tableau using external data, if necessary
 
@@ -336,6 +352,9 @@ public:
   bool OK() const;
 
 private:
+  // only PIP_Solution_Node is allowed to use the constructor and methods.
+  friend class PIP_Solution_Node;
+
   //! Pointer to the "true" child of \p *this.
   PIP_Tree_Node* true_child;
 
@@ -343,40 +362,22 @@ private:
   PIP_Tree_Node* false_child;
 
   /*! \brief
-    Constructs if \p cs then \p tcp \p else \p fcp.
-
-    Constructs a decision node controlled by \p cs (which is copied),
-    with "true" child \p tcp and "false" child \p fcp.
-
-    \param cs
-    The system of constraints controlling the node.
-
-    \exception std::invalid_argument
-    Thrown if \p cs contains strict inequalities.
-  */
-  PIP_Decision_Node(const Constraint_System& cs,
-                    PIP_Tree_Node* fcp, PIP_Tree_Node* tcp);
-
-  /*! \brief
-    Constructs if \p cs then \p tcp \p else \p fcp.
+    Constructs "if constraints then \p tcp else \p fcp". Initial constraint
+    set is empty.
 
-    Constructs a decision node controlled by \p cs (which is recycled),
+    Constructs a decision node,
     with "true" child \p tcp and "false" child \p fcp.
 
-    \param cs
-    The system of constraints controlling the node.  It is not
-    declared <CODE>const</CODE> because its data-structures may be
-    recycled to build the polyhedron.
+    \param fcp
+    Pointer to "false" child
 
-    \param dummy
-    A dummy tag to syntactically differentiate this one
-    from the other constructors.
+    \param tcp
+    Pointer to "true" child
 
     \exception std::invalid_argument
     Thrown if \p cs contains strict inequalities.
   */
-  PIP_Decision_Node(Constraint_System& cs, Recycle_Input dummy,
-                    PIP_Tree_Node* fcp, PIP_Tree_Node* tcp);
+  PIP_Decision_Node(PIP_Tree_Node* fcp, PIP_Tree_Node* tcp);
 
 protected:
   /*! \brief




More information about the PPL-devel mailing list