Improve encapsulation in HorusYap and perform other small refactorings
This commit is contained in:
parent
77dfe50acb
commit
8c2468c28b
@ -8,6 +8,7 @@
|
|||||||
#include "BeliefProp.h"
|
#include "BeliefProp.h"
|
||||||
#include "CountingBp.h"
|
#include "CountingBp.h"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int readHorusFlags (int, const char* []);
|
int readHorusFlags (int, const char* []);
|
||||||
|
@ -20,9 +20,10 @@
|
|||||||
#include "ElimGraph.h"
|
#include "ElimGraph.h"
|
||||||
#include "BayesBall.h"
|
#include "BayesBall.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Horus {
|
namespace Horus {
|
||||||
|
|
||||||
typedef std::pair<ParfactorList*, ObservedFormulas*> LiftedNetwork;
|
namespace {
|
||||||
|
|
||||||
Parfactor* readParfactor (YAP_Term);
|
Parfactor* readParfactor (YAP_Term);
|
||||||
|
|
||||||
@ -34,6 +35,10 @@ Params readParameters (YAP_Term);
|
|||||||
|
|
||||||
YAP_Term fillSolutionList (const std::vector<Params>&);
|
YAP_Term fillSolutionList (const std::vector<Params>&);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef std::pair<ParfactorList*, ObservedFormulas*> LiftedNetwork;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -66,9 +71,9 @@ createLiftedNetwork (void)
|
|||||||
// read evidence
|
// read evidence
|
||||||
ObservedFormulas* obsFormulas = readLiftedEvidence (YAP_ARG2);
|
ObservedFormulas* obsFormulas = readLiftedEvidence (YAP_ARG2);
|
||||||
|
|
||||||
LiftedNetwork* net = new LiftedNetwork (pfList, obsFormulas);
|
LiftedNetwork* network = new LiftedNetwork (pfList, obsFormulas);
|
||||||
|
|
||||||
YAP_Int p = (YAP_Int) (net);
|
YAP_Int p = (YAP_Int) (network);
|
||||||
return YAP_Unify (YAP_MkIntTerm (p), YAP_ARG3);
|
return YAP_Unify (YAP_MkIntTerm (p), YAP_ARG3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,14 +139,14 @@ int
|
|||||||
runLiftedSolver (void)
|
runLiftedSolver (void)
|
||||||
{
|
{
|
||||||
LiftedNetwork* network = (LiftedNetwork*) YAP_IntOfTerm (YAP_ARG1);
|
LiftedNetwork* network = (LiftedNetwork*) YAP_IntOfTerm (YAP_ARG1);
|
||||||
ParfactorList pfListCopy (*network->first);
|
ParfactorList copy (*network->first);
|
||||||
LiftedOperations::absorveEvidence (pfListCopy, *network->second);
|
LiftedOperations::absorveEvidence (copy, *network->second);
|
||||||
|
|
||||||
LiftedSolver* solver = 0;
|
LiftedSolver* solver = 0;
|
||||||
switch (Globals::liftedSolver) {
|
switch (Globals::liftedSolver) {
|
||||||
case LiftedSolverType::lveSolver: solver = new LiftedVe (pfListCopy); break;
|
case LiftedSolverType::lveSolver: solver = new LiftedVe (copy); break;
|
||||||
case LiftedSolverType::lbpSolver: solver = new LiftedBp (pfListCopy); break;
|
case LiftedSolverType::lbpSolver: solver = new LiftedBp (copy); break;
|
||||||
case LiftedSolverType::lkcSolver: solver = new LiftedKc (pfListCopy); break;
|
case LiftedSolverType::lkcSolver: solver = new LiftedKc (copy); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Globals::verbosity > 0) {
|
if (Globals::verbosity > 0) {
|
||||||
@ -368,6 +373,8 @@ freeLiftedNetwork (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
Parfactor*
|
Parfactor*
|
||||||
readParfactor (YAP_Term pfTerm)
|
readParfactor (YAP_Term pfTerm)
|
||||||
{
|
{
|
||||||
@ -545,6 +552,8 @@ fillSolutionList (const std::vector<Params>& results)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
|
Reference in New Issue
Block a user