workaround c++ bad design: don't allow creating a factor graph from some pointer
This commit is contained in:
parent
3f0f41c8a9
commit
f91e543d9d
@ -14,7 +14,7 @@
|
||||
FactorGraph*
|
||||
BayesBall::getMinimalFactorGraph (const VarIds& queryIds)
|
||||
{
|
||||
assert (fg_.isFromBayesNetwork());
|
||||
assert (fg_.bayesianFactors());
|
||||
Scheduling scheduling;
|
||||
for (size_t i = 0; i < queryIds.size(); i++) {
|
||||
assert (dag_.getNode (queryIds[i]));
|
||||
|
@ -28,7 +28,7 @@ FactorGraph::FactorGraph (const FactorGraph& fg)
|
||||
addEdge (varNodes_[neighs[j]->getIndex()], facNode);
|
||||
}
|
||||
}
|
||||
fromBayesNet_ = fg.isFromBayesNetwork();
|
||||
bayesFactors_ = fg.bayesianFactors();
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +239,7 @@ FactorGraph::isTree (void) const
|
||||
DAGraph&
|
||||
FactorGraph::getStructure (void)
|
||||
{
|
||||
assert (fromBayesNet_);
|
||||
assert (bayesFactors_);
|
||||
if (structure_.empty()) {
|
||||
for (size_t i = 0; i < varNodes_.size(); i++) {
|
||||
structure_.addNode (new DAGraphNode (varNodes_[i]));
|
||||
|
@ -65,7 +65,7 @@ class FacNode
|
||||
class FactorGraph
|
||||
{
|
||||
public:
|
||||
FactorGraph (bool fbn = false) : fromBayesNet_(fbn) { }
|
||||
FactorGraph (void) : bayesFactors_(false) { }
|
||||
|
||||
FactorGraph (const FactorGraph&);
|
||||
|
||||
@ -74,8 +74,10 @@ class FactorGraph
|
||||
const VarNodes& varNodes (void) const { return varNodes_; }
|
||||
|
||||
const FacNodes& facNodes (void) const { return facNodes_; }
|
||||
|
||||
void setFactorsAsBayesian (void) { bayesFactors_ = true; }
|
||||
|
||||
bool isFromBayesNetwork (void) const { return fromBayesNet_ ; }
|
||||
bool bayesianFactors (void) const { return bayesFactors_ ; }
|
||||
|
||||
size_t nrVarNodes (void) const { return varNodes_.size(); }
|
||||
|
||||
@ -128,7 +130,7 @@ class FactorGraph
|
||||
FacNodes facNodes_;
|
||||
|
||||
DAGraph structure_;
|
||||
bool fromBayesNet_;
|
||||
bool bayesFactors_;
|
||||
|
||||
typedef unordered_map<unsigned, VarNode*> VarMap;
|
||||
VarMap varMap_;
|
||||
|
@ -219,8 +219,10 @@ int
|
||||
createGroundNetwork (void)
|
||||
{
|
||||
string factorsType ((char*) YAP_AtomName (YAP_AtomOfTerm (YAP_ARG1)));
|
||||
bool fromBayesNet = factorsType == "bayes";
|
||||
FactorGraph* fg = new FactorGraph (fromBayesNet);
|
||||
FactorGraph* fg = new FactorGraph();
|
||||
if (factorsType == "bayes") {
|
||||
fg->setFactorsAsBayesian();
|
||||
}
|
||||
YAP_Term factorList = YAP_ARG2;
|
||||
while (factorList != YAP_TermNil()) {
|
||||
YAP_Term factor = YAP_HeadOfTerm (factorList);
|
||||
@ -400,7 +402,7 @@ void runVeSolver (
|
||||
results.reserve (tasks.size());
|
||||
for (size_t i = 0; i < tasks.size(); i++) {
|
||||
FactorGraph* mfg = fg;
|
||||
if (fg->isFromBayesNetwork()) {
|
||||
if (fg->bayesianFactors()) {
|
||||
// mfg = BayesBall::getMinimalFactorGraph (*fg, tasks[i]);
|
||||
}
|
||||
// VarElimSolver solver (*mfg);
|
||||
@ -410,7 +412,7 @@ void runVeSolver (
|
||||
cout << endl;
|
||||
}
|
||||
results.push_back (solver.solveQuery (tasks[i]));
|
||||
if (fg->isFromBayesNetwork()) {
|
||||
if (fg->bayesianFactors()) {
|
||||
// delete mfg;
|
||||
}
|
||||
}
|
||||
@ -429,7 +431,7 @@ void runBpSolver (
|
||||
}
|
||||
Solver* solver = 0;
|
||||
FactorGraph* mfg = fg;
|
||||
if (fg->isFromBayesNetwork()) {
|
||||
if (fg->bayesianFactors()) {
|
||||
//mfg = BayesBall::getMinimalFactorGraph (
|
||||
// *fg, VarIds (vids.begin(),vids.end()));
|
||||
}
|
||||
@ -450,7 +452,7 @@ void runBpSolver (
|
||||
for (size_t i = 0; i < tasks.size(); i++) {
|
||||
results.push_back (solver->solveQuery (tasks[i]));
|
||||
}
|
||||
if (fg->isFromBayesNetwork()) {
|
||||
if (fg->bayesianFactors()) {
|
||||
//delete mfg;
|
||||
}
|
||||
delete solver;
|
||||
|
Reference in New Issue
Block a user