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/WeightedBpSolver.h

62 lines
1.3 KiB
C
Raw Normal View History

2012-06-01 12:35:44 +01:00
#ifndef HORUS_WEIGHTEDBPSOLVER_H
#define HORUS_WEIGHTEDBPSOLVER_H
2012-05-31 21:24:15 +01:00
#include "BpSolver.h"
class WeightedLink : public BpLink
{
public:
WeightedLink (FacNode* fn, VarNode* vn, size_t idx, unsigned weight)
: BpLink (fn, vn), index_(idx), weight_(weight),
pwdMsg_(vn->range(), LogAware::one()) { }
size_t index (void) const { return index_; }
unsigned weight (void) const { return weight_; }
const Params& powMessage (void) const { return pwdMsg_; }
void updateMessage (void)
{
pwdMsg_ = *nextMsg_;
swap (currMsg_, nextMsg_);
LogAware::pow (pwdMsg_, weight_);
}
private:
size_t index_;
unsigned weight_;
Params pwdMsg_;
};
class WeightedBpSolver : public BpSolver
{
public:
WeightedBpSolver (const FactorGraph& fg,
2012-05-31 23:06:53 +01:00
const vector<vector<unsigned>>& weights)
: BpSolver (fg), weights_(weights) { }
2012-05-31 21:24:15 +01:00
~WeightedBpSolver (void);
Params getPosterioriOf (VarId);
private:
void createLinks (void);
void maxResidualSchedule (void);
void calcFactorToVarMsg (BpLink*);
Params getVarToFactorMsg (const BpLink*) const;
void printLinkInformation (void) const;
vector<vector<unsigned>> weights_;
};
2012-06-01 12:35:44 +01:00
#endif // HORUS_WEIGHTEDBPSOLVER_H
2012-05-31 21:24:15 +01:00