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/horus/CbpSolver.h

67 lines
1.2 KiB
C
Raw Normal View History

2012-05-23 14:56:01 +01:00
#ifndef HORUS_CBP_H
#define HORUS_CBP_H
#include "BpSolver.h"
#include "CFactorGraph.h"
class Factor;
class CbpSolverLink : public SpLink
{
public:
2012-05-24 22:55:20 +01:00
CbpSolverLink (FacNode* fn, VarNode* vn, size_t idx, unsigned count)
2012-05-23 14:56:01 +01:00
: SpLink (fn, vn), index_(idx), nrEdges_(count),
pwdMsg_(vn->range(), LogAware::one()) { }
2012-05-24 22:55:20 +01:00
size_t index (void) const { return index_; }
2012-05-23 14:56:01 +01:00
2012-05-24 22:55:20 +01:00
unsigned nrEdges (void) const { return nrEdges_; }
2012-05-23 14:56:01 +01:00
2012-05-28 19:41:24 +01:00
const Params& powMessage (void) const { return pwdMsg_; }
2012-05-23 14:56:01 +01:00
void updateMessage (void)
{
pwdMsg_ = *nextMsg_;
swap (currMsg_, nextMsg_);
LogAware::pow (pwdMsg_, nrEdges_);
}
private:
2012-05-24 22:55:20 +01:00
size_t index_;
2012-05-23 14:56:01 +01:00
unsigned nrEdges_;
Params pwdMsg_;
};
class CbpSolver : public BpSolver
{
public:
CbpSolver (const FactorGraph& fg);
~CbpSolver (void);
void printSolverFlags (void) const;
Params getPosterioriOf (VarId);
Params getJointDistributionOf (const VarIds&);
private:
void createLinks (void);
void maxResidualSchedule (void);
2012-05-28 19:41:24 +01:00
void calcFactorToVarMsg (SpLink*);
2012-05-23 14:56:01 +01:00
2012-05-28 19:41:24 +01:00
Params getVarToFactorMsg (const SpLink*) const;
2012-05-23 14:56:01 +01:00
void printLinkInformation (void) const;
CFactorGraph* cfg_;
};
#endif // HORUS_CBP_H