⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 beliefpropagation.h

📁 gibbs
💻 H
字号:
#ifndef BELIEFPROPAGATION_H#define BELIEFPROPAGATION_H#include "InferenceMethod.h"#include "MarkovNet.h"#include "BayesNet.h"class BeliefPropagation : public InferenceMethod{private:    const BayesNet& bnet;    MarkovNet model;    double convergenceThreshold;    double damping;public:    // Simple constructor    BeliefPropagation(const BayesNet& bn, double ratio)         : bnet(bn), model(bn), convergenceThreshold(ratio), damping(0.0)      { /* NOP */ }    virtual ~BeliefPropagation() { /* NOP */ }    virtual void runMarginalInference(const VarSet& evidence)    {        // Reset network        model.resetAllNodes();        model.resetAllMessages();        // Fix evidence variables        for (int i = 0; i < evidence.getNumVars(); i++) {            if (evidence.isTested(i)) {                // All network variables must be discrete.                model.fixNodeValue(i, (int)evidence[i]);            }        }        // Run belief propagation to convergence        model.runBP(convergenceThreshold, damping);    }    virtual double singleConditionalLogProb( const list<int>& queryVars,        const VarSet& evidence, const VarSet& answer) const { return 0; }#if 0    virtual Distribution getMarginal(int i) const {        return model.getMarginal(i);    }#endif    virtual double getMarginalProb(int i, double value) const {        Distribution m = model.getMarginal(i);        return m[(int)value];    }    virtual int getRange(int i) const { return bnet.getRange(i); }    virtual void runJointInference(const list<int>& queryVars,            const VarSet& evidence) {         cout << "ERROR: joint inference not supported "            << "using BeliefPropagation!\n";      }    virtual double getJointProb(const VarConfig& query) const {        return 0;    }};#endif // ndef BELIEFPROPAGATION_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -