initial code to support calling a lifted knowledge compilation solver

This commit is contained in:
Tiago Gomes 2012-11-08 21:54:47 +00:00
parent 0ed89d3eeb
commit 6a200760ca
4 changed files with 82 additions and 2 deletions

View File

@ -14,6 +14,7 @@
#include "LiftedBp.h"
#include "CountingBp.h"
#include "BeliefProp.h"
#include "LiftedKc.h"
#include "ElimGraph.h"
#include "BayesBall.h"
@ -76,6 +77,7 @@ createLiftedNetwork (void)
readLiftedEvidence (YAP_ARG2, *(obsFormulas));
LiftedNetwork* net = new LiftedNetwork (pfList, obsFormulas);
YAP_Int p = (YAP_Int) (net);
return YAP_Unify (YAP_MkIntTerm (p), YAP_ARG3);
}
@ -273,6 +275,8 @@ readParameters (YAP_Term paramL)
int
runLiftedSolver (void)
{
// TODO one solver instatiation should be used
// to solve several inference tasks
LiftedNetwork* network = (LiftedNetwork*) YAP_IntOfTerm (YAP_ARG1);
YAP_Term taskList = YAP_ARG2;
vector<Params> results;
@ -303,7 +307,7 @@ runLiftedSolver (void)
}
jointList = YAP_TailOfTerm (jointList);
}
if (Globals::liftedSolver == LiftedSolver::FOVE) {
if (Globals::liftedSolver == LiftedSolver::LVE) {
LiftedVe solver (pfListCopy);
if (Globals::verbosity > 0 && taskList == YAP_ARG2) {
solver.printSolverFlags();
@ -317,6 +321,13 @@ runLiftedSolver (void)
cout << endl;
}
results.push_back (solver.solveQuery (queryVars));
} else if (Globals::liftedSolver == LiftedSolver::LKC) {
LiftedKc solver (pfListCopy);
if (Globals::verbosity > 0 && taskList == YAP_ARG2) {
solver.printSolverFlags();
cout << endl;
}
results.push_back (solver.solveQuery (queryVars));
} else {
assert (false);
}

View File

@ -0,0 +1,38 @@
#include "LiftedKc.h"
#include "LiftedWCNF.h"
#include "LiftedCircuit.h"
LiftedKc::LiftedKc (const ParfactorList& pfList)
: pfList_(pfList)
{
lwcnf_ = new LiftedWCNF (pfList);
circuit_ = new LiftedCircuit (lwcnf_);
}
LiftedKc::~LiftedKc (void)
{
}
Params
LiftedKc::solveQuery (const Grounds&)
{
return Params();
}
void
LiftedKc::printSolverFlags (void) const
{
stringstream ss;
ss << "lifted kc [" ;
ss << "log_domain=" << Util::toString (Globals::logDomain);
ss << "]" ;
cout << ss.str() << endl;
}

View File

@ -0,0 +1,28 @@
#ifndef HORUS_LIFTEDKC_H
#define HORUS_LIFTEDKC_H
#include "ParfactorList.h"
class LiftedWCNF;
class LiftedCircuit;
class LiftedKc
{
public:
LiftedKc (const ParfactorList& pfList);
~LiftedKc (void);
Params solveQuery (const Grounds&);
void printSolverFlags (void) const;
private:
LiftedWCNF* lwcnf_;
LiftedCircuit* circuit_;
const ParfactorList& pfList_;
};
#endif // HORUS_LIFTEDKC_H

View File

@ -58,6 +58,7 @@ HEADERS = \
$(srcdir)/Indexer.h \
$(srcdir)/LiftedBp.h \
$(srcdir)/LiftedCircuit.h \
$(srcdir)/LiftedKc.h \
$(srcdir)/LiftedUtils.h \
$(srcdir)/LiftedVe.h \
$(srcdir)/LiftedWCNF.h \
@ -84,7 +85,8 @@ CPP_SOURCES = \
$(srcdir)/HorusCli.cpp \
$(srcdir)/HorusYap.cpp \
$(srcdir)/LiftedBp.cpp \
$(srcdir)/LiftedCircuit.h \
$(srcdir)/LiftedCircuit.cpp \
$(srcdir)/LiftedKc.cpp \
$(srcdir)/LiftedUtils.cpp \
$(srcdir)/LiftedVe.cpp \
$(srcdir)/LiftedWCNF.cpp \
@ -110,6 +112,7 @@ OBJS = \
HorusYap.o \
LiftedBp.o \
LiftedCircuit.o \
LiftedKc.o \
LiftedUtils.o \
LiftedVe.o \
LiftedWCNF.o \