adapt to changes in CFactorGraph
This commit is contained in:
parent
779f4ea2ce
commit
dd0ae564ef
@ -3,27 +3,31 @@
|
|||||||
|
|
||||||
CbpSolver::CbpSolver (const FactorGraph& fg) : BpSolver (fg)
|
CbpSolver::CbpSolver (const FactorGraph& fg) : BpSolver (fg)
|
||||||
{
|
{
|
||||||
unsigned nGroundVars, nGroundFacs, nWithoutNeighs;
|
unsigned nrGroundVars, nrGroundFacs, nrNeighborless;
|
||||||
if (Constants::COLLECT_STATS) {
|
if (Constants::COLLECT_STATS) {
|
||||||
nGroundVars = fg_->varNodes().size();
|
nrGroundVars = fg_->varNodes().size();
|
||||||
nGroundFacs = fg_->facNodes().size();
|
nrGroundFacs = fg_->facNodes().size();
|
||||||
const VarNodes& vars = fg_->varNodes();
|
const VarNodes& vars = fg_->varNodes();
|
||||||
nWithoutNeighs = 0;
|
nrNeighborless = 0;
|
||||||
for (unsigned i = 0; i < vars.size(); i++) {
|
for (unsigned i = 0; i < vars.size(); i++) {
|
||||||
const FacNodes& factors = vars[i]->neighbors();
|
const FacNodes& factors = vars[i]->neighbors();
|
||||||
if (factors.size() == 1 && factors[0]->neighbors().size() == 1) {
|
if (factors.size() == 1 && factors[0]->neighbors().size() == 1) {
|
||||||
nWithoutNeighs ++;
|
nrNeighborless ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cfg_ = new CFactorGraph (fg);
|
cfg_ = new CFactorGraph (fg);
|
||||||
fg_ = cfg_->getGroundFactorGraph();
|
fg_ = cfg_->getGroundFactorGraph();
|
||||||
if (Constants::COLLECT_STATS) {
|
if (Constants::COLLECT_STATS) {
|
||||||
unsigned nClusterVars = fg_->varNodes().size();
|
unsigned nrClusterVars = fg_->varNodes().size();
|
||||||
unsigned nClusterFacs = fg_->facNodes().size();
|
unsigned nrClusterFacs = fg_->facNodes().size();
|
||||||
Statistics::updateCompressingStatistics (nGroundVars,
|
Statistics::updateCompressingStatistics (nrGroundVars,
|
||||||
nGroundFacs, nClusterVars, nClusterFacs, nWithoutNeighs);
|
nrGroundFacs, nrClusterVars, nrClusterFacs, nrNeighborless);
|
||||||
}
|
}
|
||||||
|
// Util::printHeader ("Compressed Factor Graph");
|
||||||
|
// fg_->print();
|
||||||
|
// Util::printHeader ("Uncompressed Factor Graph");
|
||||||
|
// fg.print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,14 +121,14 @@ CbpSolver::getJointDistributionOf (const VarIds& jointVids)
|
|||||||
void
|
void
|
||||||
CbpSolver::createLinks (void)
|
CbpSolver::createLinks (void)
|
||||||
{
|
{
|
||||||
const FacClusters& fcs = cfg_->getFacClusters();
|
const FacClusters& fcs = cfg_->facClusters();
|
||||||
for (unsigned i = 0; i < fcs.size(); i++) {
|
for (unsigned i = 0; i < fcs.size(); i++) {
|
||||||
const VarClusters& vcs = fcs[i]->getVarClusters();
|
const VarClusters& vcs = fcs[i]->varClusters();
|
||||||
for (unsigned j = 0; j < vcs.size(); j++) {
|
for (unsigned j = 0; j < vcs.size(); j++) {
|
||||||
unsigned c = cfg_->getEdgeCount (fcs[i], vcs[j]);
|
unsigned c = cfg_->getEdgeCount (fcs[i], vcs[j]);
|
||||||
links_.push_back (new CbpSolverLink (
|
links_.push_back (new CbpSolverLink (
|
||||||
fcs[i]->getRepresentativeFactor(),
|
fcs[i]->getRepresentative(),
|
||||||
vcs[j]->getRepresentativeVariable(), c));
|
vcs[j]->getRepresentative(), c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +224,7 @@ CbpSolver::getVar2FactorMsg (const SpLink* link) const
|
|||||||
LogAware::pow (msg, l->nrEdges() - 1);
|
LogAware::pow (msg, l->nrEdges() - 1);
|
||||||
}
|
}
|
||||||
if (Constants::DEBUG >= 5) {
|
if (Constants::DEBUG >= 5) {
|
||||||
cout << " " << "init: " << msg << endl;
|
cout << " " << "init: " << msg << " " << src->hasEvidence() << endl;
|
||||||
}
|
}
|
||||||
const SpLinkSet& links = ninf(src)->getLinks();
|
const SpLinkSet& links = ninf(src)->getLinks();
|
||||||
if (Globals::logDomain) {
|
if (Globals::logDomain) {
|
||||||
@ -259,6 +263,7 @@ CbpSolver::printLinkInformation (void) const
|
|||||||
cout << l->toString() << ":" << endl;
|
cout << l->toString() << ":" << endl;
|
||||||
cout << " curr msg = " << l->getMessage() << endl;
|
cout << " curr msg = " << l->getMessage() << endl;
|
||||||
cout << " next msg = " << l->getNextMessage() << endl;
|
cout << " next msg = " << l->getNextMessage() << endl;
|
||||||
|
cout << " nr edges = " << l->nrEdges() << endl;
|
||||||
cout << " powered = " << l->poweredMessage() << endl;
|
cout << " powered = " << l->poweredMessage() << endl;
|
||||||
cout << " residual = " << l->getResidual() << endl;
|
cout << " residual = " << l->getResidual() << endl;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ class CbpSolverLink : public SpLink
|
|||||||
{
|
{
|
||||||
pwdMsg_ = *nextMsg_;
|
pwdMsg_ = *nextMsg_;
|
||||||
swap (currMsg_, nextMsg_);
|
swap (currMsg_, nextMsg_);
|
||||||
msgSended_ = true;
|
msgSended_ = true;
|
||||||
LogAware::pow (pwdMsg_, nrEdges_);
|
LogAware::pow (pwdMsg_, nrEdges_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user