one step close to use one solver instatiation to solve several queries
This commit is contained in:
parent
b673dfd462
commit
4522850cd6
@ -4,8 +4,8 @@
|
|||||||
#include "LiftedOperations.h"
|
#include "LiftedOperations.h"
|
||||||
|
|
||||||
|
|
||||||
LiftedBp::LiftedBp (const ParfactorList& pfList)
|
LiftedBp::LiftedBp (const ParfactorList& parfactorList)
|
||||||
: LiftedSolver (pfList), pfList_(pfList)
|
: LiftedSolver (parfactorList)
|
||||||
{
|
{
|
||||||
refineParfactors();
|
refineParfactors();
|
||||||
createFactorGraph();
|
createFactorGraph();
|
||||||
@ -82,6 +82,7 @@ LiftedBp::printSolverFlags (void) const
|
|||||||
void
|
void
|
||||||
LiftedBp::refineParfactors (void)
|
LiftedBp::refineParfactors (void)
|
||||||
{
|
{
|
||||||
|
pfList_ = parfactorList;
|
||||||
while (iterate() == false);
|
while (iterate() == false);
|
||||||
|
|
||||||
if (Globals::verbosity > 2) {
|
if (Globals::verbosity > 2) {
|
||||||
|
@ -16,7 +16,9 @@ LiftedKc::~LiftedKc (void)
|
|||||||
Params
|
Params
|
||||||
LiftedKc::solveQuery (const Grounds& query)
|
LiftedKc::solveQuery (const Grounds& query)
|
||||||
{
|
{
|
||||||
|
pfList_ = parfactorList;
|
||||||
LiftedOperations::shatterAgainstQuery (pfList_, query);
|
LiftedOperations::shatterAgainstQuery (pfList_, query);
|
||||||
|
LiftedOperations::runWeakBayesBall (pfList_, query);
|
||||||
lwcnf_ = new LiftedWCNF (pfList_);
|
lwcnf_ = new LiftedWCNF (pfList_);
|
||||||
circuit_ = new LiftedCircuit (lwcnf_);
|
circuit_ = new LiftedCircuit (lwcnf_);
|
||||||
vector<PrvGroup> groups;
|
vector<PrvGroup> groups;
|
||||||
|
@ -12,7 +12,7 @@ class LiftedKc : public LiftedSolver
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LiftedKc (const ParfactorList& pfList)
|
LiftedKc (const ParfactorList& pfList)
|
||||||
: LiftedSolver(pfList), pfList_(pfList) { }
|
: LiftedSolver(pfList) { }
|
||||||
|
|
||||||
~LiftedKc (void);
|
~LiftedKc (void);
|
||||||
|
|
||||||
@ -21,10 +21,9 @@ class LiftedKc : public LiftedSolver
|
|||||||
void printSolverFlags (void) const;
|
void printSolverFlags (void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LiftedWCNF* lwcnf_;
|
LiftedWCNF* lwcnf_;
|
||||||
LiftedCircuit* circuit_;
|
LiftedCircuit* circuit_;
|
||||||
|
ParfactorList pfList_;
|
||||||
ParfactorList pfList_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HORUS_LIFTEDKC_H
|
#endif // HORUS_LIFTEDKC_H
|
||||||
|
@ -631,6 +631,7 @@ Params
|
|||||||
LiftedVe::solveQuery (const Grounds& query)
|
LiftedVe::solveQuery (const Grounds& query)
|
||||||
{
|
{
|
||||||
assert (query.empty() == false);
|
assert (query.empty() == false);
|
||||||
|
pfList_ = parfactorList;
|
||||||
runSolver (query);
|
runSolver (query);
|
||||||
(*pfList_.begin())->normalize();
|
(*pfList_.begin())->normalize();
|
||||||
Params params = (*pfList_.begin())->params();
|
Params params = (*pfList_.begin())->params();
|
||||||
|
@ -136,7 +136,7 @@ class LiftedVe : public LiftedSolver
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LiftedVe (const ParfactorList& pfList)
|
LiftedVe (const ParfactorList& pfList)
|
||||||
: LiftedSolver(pfList), pfList_(pfList) { }
|
: LiftedSolver(pfList) { }
|
||||||
|
|
||||||
Params solveQuery (const Grounds&);
|
Params solveQuery (const Grounds&);
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ ParfactorList::ParfactorList (const ParfactorList& pfList)
|
|||||||
while (it != pfList.end()) {
|
while (it != pfList.end()) {
|
||||||
addShattered (new Parfactor (**it));
|
addShattered (new Parfactor (**it));
|
||||||
++ it;
|
++ it;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -126,6 +125,27 @@ ParfactorList::print (void) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ParfactorList&
|
||||||
|
ParfactorList::operator= (const ParfactorList& pfList)
|
||||||
|
{
|
||||||
|
if (this != &pfList) {
|
||||||
|
ParfactorList::const_iterator it0 = pfList_.begin();
|
||||||
|
while (it0 != pfList_.end()) {
|
||||||
|
delete *it0;
|
||||||
|
++ it0;
|
||||||
|
}
|
||||||
|
pfList_.clear();
|
||||||
|
ParfactorList::const_iterator it = pfList.begin();
|
||||||
|
while (it != pfList.end()) {
|
||||||
|
addShattered (new Parfactor (**it));
|
||||||
|
++ it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ParfactorList::isShattered (const Parfactor* g) const
|
ParfactorList::isShattered (const Parfactor* g) const
|
||||||
{
|
{
|
||||||
|
@ -56,6 +56,8 @@ class ParfactorList
|
|||||||
bool isAllShattered (void) const;
|
bool isAllShattered (void) const;
|
||||||
|
|
||||||
void print (void) const;
|
void print (void) const;
|
||||||
|
|
||||||
|
ParfactorList& operator= (const ParfactorList& pfList);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user