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

65 lines
1.3 KiB
C
Raw Normal View History

#ifndef HORUS_WEIGHTEDBP_H
#define HORUS_WEIGHTEDBP_H
2012-05-31 21:24:15 +01:00
#include "BeliefProp.h"
2012-05-31 21:24:15 +01:00
class WeightedLink : public BpLink
{
public:
2012-12-20 23:19:10 +00:00
WeightedLink (FacNode* fn, VarNode* vn, size_t idx, unsigned weight)
2012-05-31 21:24:15 +01:00
: 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_; }
2012-12-20 23:19:10 +00:00
void updateMessage (void)
2012-05-31 21:24:15 +01:00
{
pwdMsg_ = *nextMsg_;
swap (currMsg_, nextMsg_);
LogAware::pow (pwdMsg_, weight_);
}
2012-12-17 18:39:42 +00:00
2012-05-31 21:24:15 +01:00
private:
2012-12-27 22:25:45 +00:00
DISALLOW_COPY_AND_ASSIGN (WeightedLink);
2012-05-31 21:24:15 +01:00
size_t index_;
unsigned weight_;
Params pwdMsg_;
};
class WeightedBp : public BeliefProp
2012-05-31 21:24:15 +01:00
{
2012-12-17 18:39:42 +00:00
public:
WeightedBp (const FactorGraph& fg,
2012-05-31 23:06:53 +01:00
const vector<vector<unsigned>>& weights)
: BeliefProp (fg), weights_(weights) { }
2012-05-31 21:24:15 +01:00
~WeightedBp (void);
2012-12-17 18:39:42 +00:00
2012-05-31 21:24:15 +01:00
Params getPosterioriOf (VarId);
private:
void createLinks (void);
void maxResidualSchedule (void);
void calcFactorToVarMsg (BpLink*);
Params getVarToFactorMsg (const BpLink*) const;
void printLinkInformation (void) const;
2012-12-17 18:39:42 +00:00
2012-05-31 21:24:15 +01:00
vector<vector<unsigned>> weights_;
2012-12-27 22:25:45 +00:00
DISALLOW_COPY_AND_ASSIGN (WeightedBp);
2012-05-31 21:24:15 +01:00
};
#endif // HORUS_WEIGHTEDBP_H
2012-05-31 21:24:15 +01:00