more work to support inference with lifted knowledge compilation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "LiftedKc.h"
|
||||
#include "LiftedWCNF.h"
|
||||
#include "LiftedCircuit.h"
|
||||
#include "Indexer.h"
|
||||
|
||||
|
||||
LiftedKc::LiftedKc (const ParfactorList& pfList)
|
||||
@@ -19,9 +20,46 @@ LiftedKc::~LiftedKc (void)
|
||||
|
||||
|
||||
Params
|
||||
LiftedKc::solveQuery (const Grounds&)
|
||||
LiftedKc::solveQuery (const Grounds& query)
|
||||
{
|
||||
return Params();
|
||||
vector<PrvGroup> groups;
|
||||
Ranges ranges;
|
||||
for (size_t i = 0; i < query.size(); i++) {
|
||||
ParfactorList::const_iterator it = pfList_.begin();
|
||||
while (it != pfList_.end()) {
|
||||
size_t idx = (*it)->indexOfGround (query[i]);
|
||||
if (idx != (*it)->nrArguments()) {
|
||||
groups.push_back ((*it)->argument (idx).group());
|
||||
ranges.push_back ((*it)->range (idx));
|
||||
break;
|
||||
}
|
||||
++ it;
|
||||
}
|
||||
}
|
||||
cout << "groups: " << groups << endl;
|
||||
cout << "ranges: " << ranges << endl;
|
||||
Params params;
|
||||
Indexer indexer (ranges);
|
||||
while (indexer.valid()) {
|
||||
for (size_t i = 0; i < groups.size(); i++) {
|
||||
vector<LiteralId> litIds = lwcnf_->prvGroupLiterals (groups[i]);
|
||||
for (size_t j = 0; j < litIds.size(); j++) {
|
||||
if (indexer[i] == j) {
|
||||
lwcnf_->addWeight (litIds[j], 1.0, 1.0); // TODO not log aware
|
||||
} else {
|
||||
lwcnf_->addWeight (litIds[j], 0.0, 1.0); // TODO not log aware
|
||||
}
|
||||
}
|
||||
}
|
||||
// cout << "new weights ----- ----- -----" << endl;
|
||||
// lwcnf_->printWeights();
|
||||
// circuit_->exportToGraphViz ("ccircuit.dot");
|
||||
params.push_back (circuit_->getWeightedModelCount());
|
||||
++ indexer;
|
||||
}
|
||||
cout << "params: " << params << endl;
|
||||
LogAware::normalize (params);
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user