fix debuging information and s/ds/range
This commit is contained in:
parent
66353e67ec
commit
779f4ea2ce
@ -291,12 +291,19 @@ BpSolver::calculateFactor2VariableMsg (SpLink* link)
|
|||||||
if (Globals::logDomain) {
|
if (Globals::logDomain) {
|
||||||
for (int i = links.size() - 1; i >= 0; i--) {
|
for (int i = links.size() - 1; i >= 0; i--) {
|
||||||
if (links[i]->getVariable() != dst) {
|
if (links[i]->getVariable() != dst) {
|
||||||
|
if (Constants::DEBUG >= 5) {
|
||||||
|
cout << " message from " << links[i]->getVariable()->label();
|
||||||
|
cout << ": " ;
|
||||||
|
}
|
||||||
Util::add (msgProduct, getVar2FactorMsg (links[i]), repetitions);
|
Util::add (msgProduct, getVar2FactorMsg (links[i]), repetitions);
|
||||||
repetitions *= links[i]->getVariable()->range();
|
repetitions *= links[i]->getVariable()->range();
|
||||||
|
if (Constants::DEBUG >= 5) {
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned ds = links[i]->getVariable()->range();
|
unsigned range = links[i]->getVariable()->range();
|
||||||
Util::add (msgProduct, Params (ds, 1.0), repetitions);
|
Util::add (msgProduct, Params (range, 0.0), repetitions);
|
||||||
repetitions *= ds;
|
repetitions *= range;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -304,14 +311,17 @@ BpSolver::calculateFactor2VariableMsg (SpLink* link)
|
|||||||
if (links[i]->getVariable() != dst) {
|
if (links[i]->getVariable() != dst) {
|
||||||
if (Constants::DEBUG >= 5) {
|
if (Constants::DEBUG >= 5) {
|
||||||
cout << " message from " << links[i]->getVariable()->label();
|
cout << " message from " << links[i]->getVariable()->label();
|
||||||
cout << ": " << endl;
|
cout << ": " ;
|
||||||
}
|
}
|
||||||
Util::multiply (msgProduct, getVar2FactorMsg (links[i]), repetitions);
|
Util::multiply (msgProduct, getVar2FactorMsg (links[i]), repetitions);
|
||||||
repetitions *= links[i]->getVariable()->range();
|
repetitions *= links[i]->getVariable()->range();
|
||||||
|
if (Constants::DEBUG >= 5) {
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned ds = links[i]->getVariable()->range();
|
unsigned range = links[i]->getVariable()->range();
|
||||||
Util::multiply (msgProduct, Params (ds, 1.0), repetitions);
|
Util::multiply (msgProduct, Params (range, 1.0), repetitions);
|
||||||
repetitions *= ds;
|
repetitions *= range;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,9 +362,6 @@ BpSolver::getVar2FactorMsg (const SpLink* link) const
|
|||||||
if (src->hasEvidence()) {
|
if (src->hasEvidence()) {
|
||||||
msg.resize (src->range(), LogAware::noEvidence());
|
msg.resize (src->range(), LogAware::noEvidence());
|
||||||
msg[src->getEvidence()] = LogAware::withEvidence();
|
msg[src->getEvidence()] = LogAware::withEvidence();
|
||||||
if (Constants::DEBUG >= 5) {
|
|
||||||
cout << msg;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
msg.resize (src->range(), LogAware::one());
|
msg.resize (src->range(), LogAware::one());
|
||||||
}
|
}
|
||||||
@ -366,6 +373,9 @@ BpSolver::getVar2FactorMsg (const SpLink* link) const
|
|||||||
for (unsigned i = 0; i < links.size(); i++) {
|
for (unsigned i = 0; i < links.size(); i++) {
|
||||||
if (links[i]->getFactor() != dst) {
|
if (links[i]->getFactor() != dst) {
|
||||||
Util::add (msg, links[i]->getMessage());
|
Util::add (msg, links[i]->getMessage());
|
||||||
|
if (Constants::DEBUG >= 5) {
|
||||||
|
cout << " x " << links[i]->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user