2011-12-12 15:29:51 +00:00
|
|
|
#ifndef HORUS_CBP_H
|
|
|
|
#define HORUS_CBP_H
|
|
|
|
|
2012-04-05 23:00:48 +01:00
|
|
|
#include "BpSolver.h"
|
2011-12-12 15:29:51 +00:00
|
|
|
#include "CFactorGraph.h"
|
|
|
|
|
|
|
|
class Factor;
|
|
|
|
|
|
|
|
class CbpSolverLink : public SpLink
|
|
|
|
{
|
|
|
|
public:
|
2012-04-10 20:43:08 +01:00
|
|
|
CbpSolverLink (FacNode* fn, VarNode* vn, unsigned c)
|
|
|
|
: SpLink (fn, vn), nrEdges_(c),
|
|
|
|
pwdMsg_(vn->range(), LogAware::one()) { }
|
2011-12-12 15:29:51 +00:00
|
|
|
|
2012-04-10 20:43:08 +01:00
|
|
|
unsigned nrEdges (void) const { return nrEdges_; }
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2012-04-10 20:43:08 +01:00
|
|
|
const Params& poweredMessage (void) const { return pwdMsg_; }
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2011-12-12 15:29:51 +00:00
|
|
|
void updateMessage (void)
|
|
|
|
{
|
2012-04-10 20:43:08 +01:00
|
|
|
pwdMsg_ = *nextMsg_;
|
2011-12-12 15:29:51 +00:00
|
|
|
swap (currMsg_, nextMsg_);
|
|
|
|
msgSended_ = true;
|
2012-04-10 20:43:08 +01:00
|
|
|
LogAware::pow (pwdMsg_, nrEdges_);
|
2011-12-12 15:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2012-04-10 20:43:08 +01:00
|
|
|
unsigned nrEdges_;
|
|
|
|
Params pwdMsg_;
|
2011-12-12 15:29:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-05 23:00:48 +01:00
|
|
|
class CbpSolver : public BpSolver
|
2011-12-12 15:29:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-04-10 20:43:08 +01:00
|
|
|
CbpSolver (const FactorGraph& fg);
|
2012-03-31 23:27:37 +01:00
|
|
|
|
2011-12-12 15:29:51 +00:00
|
|
|
~CbpSolver (void);
|
2012-04-10 20:43:08 +01:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
Params getPosterioriOf (VarId);
|
2011-12-12 15:29:51 +00:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
Params getJointDistributionOf (const VarIds&);
|
2011-12-12 15:29:51 +00:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
private:
|
2012-04-10 15:00:18 +01:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
void createLinks (void);
|
2011-12-12 15:29:51 +00:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
void maxResidualSchedule (void);
|
2012-04-10 15:00:18 +01:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
Params getVar2FactorMsg (const SpLink*) const;
|
2012-04-10 15:00:18 +01:00
|
|
|
|
2012-03-31 23:27:37 +01:00
|
|
|
void printLinkInformation (void) const;
|
2011-12-12 15:29:51 +00:00
|
|
|
|
2012-04-10 20:43:08 +01:00
|
|
|
CFactorGraph* cfg_;
|
2011-12-12 15:29:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HORUS_CBP_H
|
|
|
|
|