From 2061eefda2d61a94e72f8b248a13c7915c98739f Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Tue, 15 May 2012 16:43:32 +0100 Subject: [PATCH] add a way to copy a log var --- packages/CLPBN/clpbn/bp/ConstraintTree.cpp | 15 +++++++++++++++ packages/CLPBN/clpbn/bp/ConstraintTree.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/packages/CLPBN/clpbn/bp/ConstraintTree.cpp b/packages/CLPBN/clpbn/bp/ConstraintTree.cpp index 56c54e4e9..94d49e111 100644 --- a/packages/CLPBN/clpbn/bp/ConstraintTree.cpp +++ b/packages/CLPBN/clpbn/bp/ConstraintTree.cpp @@ -856,6 +856,21 @@ ConstraintTree::ground (LogVar X) +void +ConstraintTree::copyLogVar (LogVar X_1, LogVar X_2) +{ + moveToBottom ({X_1}); + CTNodes leafs = getNodesAtLevel (logVars_.size()); + for (unsigned i = 0; i < leafs.size(); i++) { + leafs[i]->childs().push_back ( + new CTNode (leafs[i]->symbol(), leafs[i]->level() + 1)); + } + logVars_.push_back (X_2); + logVarSet_.insert (X_2); +} + + + unsigned ConstraintTree::countTuples (const CTNode* n) const { diff --git a/packages/CLPBN/clpbn/bp/ConstraintTree.h b/packages/CLPBN/clpbn/bp/ConstraintTree.h index 59b1a9bb0..1cf849084 100644 --- a/packages/CLPBN/clpbn/bp/ConstraintTree.h +++ b/packages/CLPBN/clpbn/bp/ConstraintTree.h @@ -207,6 +207,8 @@ class ConstraintTree LogVars expand (LogVar); ConstraintTrees ground (LogVar); + + void copyLogVar (LogVar,LogVar); private: unsigned countTuples (const CTNode*) const;