Move BpLink to inside of BeliefProp
This commit is contained in:
@@ -12,55 +12,6 @@
|
||||
|
||||
namespace Horus {
|
||||
|
||||
BpLink::BpLink (FacNode* fn, VarNode* vn)
|
||||
{
|
||||
fac_ = fn;
|
||||
var_ = vn;
|
||||
v1_.resize (vn->range(), LogAware::log (1.0 / vn->range()));
|
||||
v2_.resize (vn->range(), LogAware::log (1.0 / vn->range()));
|
||||
currMsg_ = &v1_;
|
||||
nextMsg_ = &v2_;
|
||||
residual_ = 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
BpLink::clearResidual (void)
|
||||
{
|
||||
residual_ = 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
BpLink::updateResidual (void)
|
||||
{
|
||||
residual_ = LogAware::getMaxNorm (v1_, v2_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
BpLink::updateMessage (void)
|
||||
{
|
||||
swap (currMsg_, nextMsg_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string
|
||||
BpLink::toString (void) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << fac_->getLabel();
|
||||
ss << " -- " ;
|
||||
ss << var_->label();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
double BeliefProp::accuracy_ = 0.0001;
|
||||
unsigned BeliefProp::maxIter_ = 1000;
|
||||
|
||||
@@ -207,6 +158,55 @@ BeliefProp::getFactorJoint (
|
||||
|
||||
|
||||
|
||||
BeliefProp::BpLink::BpLink (FacNode* fn, VarNode* vn)
|
||||
{
|
||||
fac_ = fn;
|
||||
var_ = vn;
|
||||
v1_.resize (vn->range(), LogAware::log (1.0 / vn->range()));
|
||||
v2_.resize (vn->range(), LogAware::log (1.0 / vn->range()));
|
||||
currMsg_ = &v1_;
|
||||
nextMsg_ = &v2_;
|
||||
residual_ = 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
BeliefProp::BpLink::clearResidual (void)
|
||||
{
|
||||
residual_ = 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
BeliefProp::BpLink::updateResidual (void)
|
||||
{
|
||||
residual_ = LogAware::getMaxNorm (v1_, v2_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
BeliefProp::BpLink::updateMessage (void)
|
||||
{
|
||||
swap (currMsg_, nextMsg_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string
|
||||
BeliefProp::BpLink::toString (void) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << fac_->getLabel();
|
||||
ss << " -- " ;
|
||||
ss << var_->label();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
BeliefProp::calculateAndUpdateMessage (BpLink* link, bool calcResidual)
|
||||
{
|
||||
|
Reference in New Issue
Block a user