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

70 lines
1.4 KiB
C
Raw Normal View History

2013-02-07 17:50:02 +00:00
#ifndef YAP_PACKAGES_CLPBN_HORUS_WEIGHTEDBP_H_
#define YAP_PACKAGES_CLPBN_HORUS_WEIGHTEDBP_H_
2012-05-31 21:24:15 +01:00
#include "BeliefProp.h"
2012-05-31 21:24:15 +01:00
namespace Horus {
2013-02-07 23:53:13 +00:00
2013-02-20 23:59:03 +00:00
class WeightedBp : public BeliefProp {
2012-05-31 21:24:15 +01:00
public:
2013-02-20 23:59:03 +00:00
WeightedBp (const FactorGraph& fg,
const std::vector<std::vector<unsigned>>& weights);
2012-05-31 21:24:15 +01:00
~WeightedBp();
2012-05-31 21:24:15 +01:00
2013-02-20 23:59:03 +00:00
Params getPosterioriOf (VarId);
2012-05-31 21:24:15 +01:00
2013-02-20 23:59:03 +00:00
private:
class WeightedLink : public BeliefProp::BpLink {
public:
WeightedLink (FacNode* fn, VarNode* vn, size_t idx,
unsigned weight);
2012-05-31 21:24:15 +01:00
size_t index() const { return index_; }
2012-12-17 18:39:42 +00:00
unsigned weight() const { return weight_; }
2012-12-27 22:25:45 +00:00
const Params& powMessage() const { return pwdMsg_; }
2012-05-31 21:24:15 +01:00
void updateMessage();
2012-05-31 21:24:15 +01:00
2013-02-20 23:59:03 +00:00
private:
size_t index_;
unsigned weight_;
Params pwdMsg_;
DISALLOW_COPY_AND_ASSIGN (WeightedLink);
2013-02-20 23:59:03 +00:00
};
void createLinks();
2012-05-31 21:24:15 +01:00
void maxResidualSchedule();
2012-05-31 21:24:15 +01:00
void calcFactorToVarMsg (BpLink*);
2013-03-09 16:41:53 +00:00
Params getVarToFactorMsg (const BpLink*);
2012-05-31 21:24:15 +01:00
void printLinkInformation() const;
2012-12-17 18:39:42 +00:00
2013-02-07 13:37:15 +00:00
std::vector<std::vector<unsigned>> weights_;
2012-12-27 22:25:45 +00:00
DISALLOW_COPY_AND_ASSIGN (WeightedBp);
2012-05-31 21:24:15 +01:00
};
2013-02-20 23:59:03 +00:00
inline void
WeightedBp::WeightedLink::updateMessage()
2013-02-20 23:59:03 +00:00
{
pwdMsg_ = *nextMsg_;
swap (currMsg_, nextMsg_);
LogAware::pow (pwdMsg_, weight_);
}
} // namespace Horus
2013-02-07 23:53:13 +00:00
2013-02-08 00:20:01 +00:00
#endif // YAP_PACKAGES_CLPBN_HORUS_WEIGHTEDBP_H_
2012-05-31 21:24:15 +01:00