[GIT] ppl/ppl(pip): Added reference to the Problem object in solution tree Nodes.

Module: ppl/ppl Branch: pip Commit: a6ea14f4ac3f3c9d64b4f0d3db728cec03ff7c9c URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=a6ea14f4ac3f3...
Author: François Galea francois.galea@uvsq.fr Date: Tue Sep 22 09:30:53 2009 +0200
Added reference to the Problem object in solution tree Nodes.
---
src/PIP_Problem.cc | 2 +- src/PIP_Problem.defs.hh | 1 + src/PIP_Tree.cc | 25 +++++++++++++++---------- src/PIP_Tree.defs.hh | 9 ++++++--- 4 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/src/PIP_Problem.cc b/src/PIP_Problem.cc index ec42436..6d651fa 100644 --- a/src/PIP_Problem.cc +++ b/src/PIP_Problem.cc @@ -77,7 +77,7 @@ PPL::PIP_Problem::solve() const { PIP_Problem_Status return_value;
if (current_solution == 0) - x.current_solution = new PIP_Solution_Node(); + x.current_solution = new PIP_Solution_Node(&x);
x.current_solution->update_tableau(&x.current_solution, external_space_dim, diff --git a/src/PIP_Problem.defs.hh b/src/PIP_Problem.defs.hh index 58ebff5..3accf0e 100644 --- a/src/PIP_Problem.defs.hh +++ b/src/PIP_Problem.defs.hh @@ -83,6 +83,7 @@ operator<<(std::ostream& s, const PIP_Problem& p); the change of objective function and the change of optimization mode. */ class Parma_Polyhedra_Library::PIP_Problem { + friend class PIP_Solution_Node; public: //! Builds a trivial PIP problem. /*! diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc index 45d25e1..b81d10b 100644 --- a/src/PIP_Tree.cc +++ b/src/PIP_Tree.cc @@ -22,6 +22,7 @@ site: http://www.cs.unipr.it/ppl/ . */
#include <ppl-config.h> #include "PIP_Tree.defs.hh" +#include "PIP_Problem.defs.hh"
#include <algorithm>
@@ -64,12 +65,14 @@ negate_assign(Row& x, const Row& y) {
} // namespace
-PIP_Tree_Node::PIP_Tree_Node() - : constraints_() { +PIP_Tree_Node::PIP_Tree_Node(PIP_Problem* p) + : problem(p), + constraints_() { }
PIP_Tree_Node::PIP_Tree_Node(const PIP_Tree_Node &x) - : constraints_(x.constraints_) { + : problem(x.problem), + constraints_(x.constraints_) { }
PIP_Decision_Node::~PIP_Decision_Node() { @@ -81,8 +84,8 @@ PIP_Decision_Node::~PIP_Decision_Node() { PIP_Solution_Node::~PIP_Solution_Node() { }
-PIP_Solution_Node::PIP_Solution_Node() - : PIP_Tree_Node(), +PIP_Solution_Node::PIP_Solution_Node(PIP_Problem* p) + : PIP_Tree_Node(p), tableau(), basis(), mapping(), @@ -99,7 +102,7 @@ PIP_Solution_Node::PIP_Solution_Node(const PIP_Solution_Node &x)
PIP_Solution_Node::PIP_Solution_Node(const PIP_Solution_Node &x, bool empty_constraints) - : PIP_Tree_Node(), + : PIP_Tree_Node(x.problem), tableau(x.tableau), basis(x.basis), mapping(x.mapping), @@ -108,8 +111,10 @@ PIP_Solution_Node::PIP_Solution_Node(const PIP_Solution_Node &x, constraints_ = x.constraints_; }
-PIP_Decision_Node::PIP_Decision_Node(PIP_Tree_Node* fcp, PIP_Tree_Node* tcp) - : PIP_Tree_Node(), +PIP_Decision_Node::PIP_Decision_Node(PIP_Problem* p, + PIP_Tree_Node* fcp, + PIP_Tree_Node* tcp) + : PIP_Tree_Node(p), true_child(tcp), false_child(fcp) { } @@ -882,13 +887,13 @@ PIP_Solution_Node::solve(PIP_Tree_Node*& parent_ref, }
/* Create a decision Node to become parent of current Node */ - PIP_Decision_Node *parent = new PIP_Decision_Node(fals, tru); + PIP_Decision_Node *parent = new PIP_Decision_Node(problem, fals, tru); parent->add_constraint(test);
if (!cs.empty()) { /* If node to be solved had tautologies, store them in a new decision node */ - parent = new PIP_Decision_Node(0, parent); + parent = new PIP_Decision_Node(problem, 0, parent); cs.swap(parent->constraints_); }
diff --git a/src/PIP_Tree.defs.hh b/src/PIP_Tree.defs.hh index 7ac9ec2..fcbd62e 100644 --- a/src/PIP_Tree.defs.hh +++ b/src/PIP_Tree.defs.hh @@ -75,7 +75,7 @@ public:
protected: //! Default constructor. - PIP_Tree_Node(); + PIP_Tree_Node(PIP_Problem* p);
//! Copy constructor. PIP_Tree_Node(const PIP_Tree_Node &x); @@ -89,6 +89,9 @@ protected: friend class PIP_Decision_Node; friend class PIP_Solution_Node;
+ //! A pointer to the master problem object. + PIP_Problem* problem; + //! The local system of parameter constraints. Constraint_System constraints_;
@@ -141,7 +144,7 @@ protected: class PIP_Solution_Node : public PIP_Tree_Node { public: //! Default constructor. - PIP_Solution_Node(); + PIP_Solution_Node(PIP_Problem* p);
//! Destructor. ~PIP_Solution_Node(); @@ -383,7 +386,7 @@ private: \exception std::invalid_argument Thrown if \p cs contains strict inequalities. */ - PIP_Decision_Node(PIP_Tree_Node* fcp, PIP_Tree_Node* tcp); + PIP_Decision_Node(PIP_Problem* p, PIP_Tree_Node* fcp, PIP_Tree_Node* tcp);
protected: /*! \brief
participants (1)
-
François Galea