[GIT] ppl/ppl(pip): Added first tests in OK() methods of PIP_Tree classes.

Module: ppl/ppl Branch: pip Commit: 0c02e3b5a945d83ad4760bb4e014614442769464 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=0c02e3b5a945d...
Author: François Galea francois.galea@uvsq.fr Date: Fri Sep 11 16:24:49 2009 +0200
Added first tests in OK() methods of PIP_Tree classes.
---
src/PIP_Tree.cc | 80 ++++++++++++++++++++++++++++++++++++++++++++++++- src/PIP_Tree.defs.hh | 13 ++++---- 2 files changed, 84 insertions(+), 9 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc index 9a768c9..b7948f5 100644 --- a/src/PIP_Tree.cc +++ b/src/PIP_Tree.cc @@ -97,14 +97,90 @@ PIP_Decision_Node::as_decision() { }
bool +PIP_Solution_Node::Tableau::OK() const { +#ifndef NDEBUG + using std::endl; + using std::cerr; +#endif + + const dimension_type num_rows = s.num_rows(); + if (num_rows != t.num_rows()) { +#ifndef NDEBUG + cerr << "The PIP_Solution_Node::Tableau matrices do not have the " + << "same number of rows." + << endl; +#endif + return false; + } + return true; +} + +bool +PIP_Tree_Node::OK() const { +#ifndef NDEBUG + using std::endl; + using std::cerr; +#endif + Constraint_System::const_iterator begin = constraints_.begin(); + Constraint_System::const_iterator end = constraints_.end(); + + // Parameter constraint system should contain no strict inequalities. + for (Constraint_System::const_iterator c = begin; c != end; c++) + if (c->is_strict_inequality()) { +#ifndef NDEBUG + cerr << "The feasible region of the PIP_Problem parameter context" + << "is defined by a constraint system containing strict " + << "inequalities." + << endl; + ascii_dump(cerr); +#endif + return false; + } + return true; +} + +bool PIP_Solution_Node::OK() const { - /* FIXME: write me! */ + /* FIXME: finish me! */ +#ifndef NDEBUG + using std::endl; + using std::cerr; +#endif + if (!PIP_Tree_Node::OK()) + return false; + + // Check that every member used is OK. + + if (!tableau.OK()) + return false; + return true; }
bool PIP_Decision_Node::OK() const { - /* FIXME: write me! */ + /* FIXME: finish me! */ +#ifndef NDEBUG + using std::endl; + using std::cerr; +#endif + if (!PIP_Tree_Node::OK()) + return false; + + // Decision nodes with false child must have exactly one constraint + if (false_child) { + dimension_type + dist = std::distance(constraints_.begin(), constraints_.end()); + if (dist != 1) { +#ifndef NDEBUG + cerr << "The PIP_Decision_Node has a 'false' child but does not " + << "have exactly one parametric constraint. (" << dist << ")" + << endl; +#endif + return false; + } + } + return true; }
diff --git a/src/PIP_Tree.defs.hh b/src/PIP_Tree.defs.hh index 5a3f476..acb8b2a 100644 --- a/src/PIP_Tree.defs.hh +++ b/src/PIP_Tree.defs.hh @@ -58,7 +58,7 @@ public: virtual ~PIP_Tree_Node();
//! Returns \c true if and only if \p *this is well formed. - virtual bool OK() const = 0; + bool OK() const;
protected: //! A type alias for a sequence of constraints. @@ -69,6 +69,9 @@ protected: friend class PIP_Problem; friend class PIP_Decision_Node;
+ //! The local system of parameter constraints. + Constraint_System constraints_; + /*! \brief Populates the parametric simplex tableau using external data, if necessary
@@ -206,6 +209,8 @@ private: Rational_Matrix s; //! The matrix of parameter coefficients. Rational_Matrix t; + //! Returns \c true if and only if \p *this is well formed. + bool OK() const; };
//! The parametric simplex tableau. @@ -249,9 +254,6 @@ private: //! A cache for computed sign values of constraint parametric RHS. std::vector<Row_Sign> sign;
- //! The local system of parameter constraints. - Constraint_System constraints_; - //! Determines the sign of given Row. static Row_Sign row_sign(const Row &x);
@@ -347,9 +349,6 @@ private: //! Pointer to the "false" child of \p *this. PIP_Tree_Node* false_child;
- //! The local system of parameter constraints - Constraint_System constraints_; - /*! \brief Constructs if \p cs then \p tcp \p else \p fcp.
participants (1)
-
François Galea