[GIT] ppl/ppl(pip): Improved consistency checks in method PIP_Decision_Node ::OK().

Module: ppl/ppl Branch: pip Commit: b728ad412284bf04adf16ae4dba749b4f0627651 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=b728ad412284b...
Author: Enea Zaffanella zaffanella@cs.unipr.it Date: Sat Jan 30 20:50:27 2010 +0100
Improved consistency checks in method PIP_Decision_Node::OK().
---
src/PIP_Tree.cc | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc index 800992b..3e42b9f 100644 --- a/src/PIP_Tree.cc +++ b/src/PIP_Tree.cc @@ -569,27 +569,31 @@ PIP_Solution_Node::OK() const { bool PIP_Decision_Node::OK() const { /* FIXME: finish me! */ -#ifndef NDEBUG - using std::endl; - using std::cerr; -#endif + + // Perform base class well-formedness check on this node. if (!PIP_Tree_Node::OK()) return false;
- // Decision nodes with false child must have exactly one constraint + // Recursively check if child nodes are well-formed. + if (true_child && !true_child->OK()) + return false; + if (false_child && !false_child->OK()) + return false; + + // Decision nodes with a false child must have exactly one constraint. if (false_child) { dimension_type - dist = std::distance(constraints_.begin(), constraints_.end()); + 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; + std::cerr << "PIP_Decision_Node with a 'false' child has " + << dist << " parametric constraints (should be 1).\n"; #endif return false; } }
+ // All checks passed. return true; }
participants (1)
-
Enea Zaffanella