This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/CLPBN/clpbn/bp/CbpSolver.h

61 lines
1.2 KiB
C
Raw Normal View History

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 11:51:56 +01:00
CbpSolverLink (FacNode* fn, VarNode* vn, unsigned c) : SpLink (fn, vn)
2011-12-12 15:29:51 +00:00
{
edgeCount_ = c;
2012-04-05 18:38:56 +01:00
poweredMsg_.resize (vn->range(), LogAware::one());
2011-12-12 15:29:51 +00:00
}
2012-03-31 23:27:37 +01:00
unsigned getNumberOfEdges (void) const { return edgeCount_; }
const Params& getPoweredMessage (void) const { return poweredMsg_; }
2011-12-12 15:29:51 +00:00
void updateMessage (void)
{
poweredMsg_ = *nextMsg_;
swap (currMsg_, nextMsg_);
msgSended_ = true;
2012-03-31 23:27:37 +01:00
LogAware::pow (poweredMsg_, edgeCount_);
2011-12-12 15:29:51 +00:00
}
private:
2012-03-31 23:27:37 +01:00
Params poweredMsg_;
unsigned edgeCount_;
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-05 23:00:48 +01:00
CbpSolver (FactorGraph& fg) : BpSolver (fg) { }
2012-03-31 23:27:37 +01:00
2011-12-12 15:29:51 +00:00
~CbpSolver (void);
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:
void initializeSolver (void);
void createLinks (void);
2011-12-12 15:29:51 +00:00
2012-03-31 23:27:37 +01:00
void maxResidualSchedule (void);
Params getVar2FactorMsg (const SpLink*) const;
void printLinkInformation (void) const;
2011-12-12 15:29:51 +00:00
2012-04-05 18:38:56 +01:00
CFactorGraph* lfg_;
2011-12-12 15:29:51 +00:00
};
#endif // HORUS_CBP_H