workaround c++ bad design: don't allow creating a factor graph from some pointer

This commit is contained in:
Tiago Gomes
2012-05-31 22:42:38 +01:00
parent 3f0f41c8a9
commit f91e543d9d
4 changed files with 16 additions and 12 deletions

View File

@@ -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;