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/clpbn/bp/GraphicalModel.h

65 lines
1.2 KiB
C
Raw Normal View History

2011-12-12 15:29:51 +00:00
#ifndef HORUS_GRAPHICALMODEL_H
#define HORUS_GRAPHICALMODEL_H
2012-03-31 23:27:37 +01:00
#include <cassert>
#include <unordered_map>
2012-03-22 11:33:24 +00:00
#include <sstream>
2011-12-12 15:29:51 +00:00
#include "VarNode.h"
2012-03-31 23:27:37 +01:00
#include "Util.h"
2012-03-22 11:33:24 +00:00
#include "Horus.h"
2011-12-12 15:29:51 +00:00
using namespace std;
2012-03-22 11:33:24 +00:00
2012-03-31 23:27:37 +01:00
struct VarInfo
2011-12-12 15:29:51 +00:00
{
2012-03-31 23:27:37 +01:00
VarInfo (string l, const States& sts) : label(l), states(sts) { }
string label;
States states;
2011-12-12 15:29:51 +00:00
};
class GraphicalModel
{
public:
2012-03-31 23:27:37 +01:00
virtual ~GraphicalModel (void) { };
virtual VarNode* getVariableNode (VarId) const = 0;
virtual VarNodes getVariableNodes (void) const = 0;
virtual void printGraphicalModel (void) const = 0;
2011-12-12 15:29:51 +00:00
2012-03-31 23:27:37 +01:00
static void addVariableInformation (
VarId vid, string label, const States& states)
2011-12-12 15:29:51 +00:00
{
2012-03-31 23:27:37 +01:00
assert (Util::contains (varsInfo_, vid) == false);
varsInfo_.insert (make_pair (vid, VarInfo (label, states)));
2011-12-12 15:29:51 +00:00
}
2012-03-31 23:27:37 +01:00
static VarInfo getVarInformation (VarId vid)
2011-12-12 15:29:51 +00:00
{
2012-03-31 23:27:37 +01:00
assert (Util::contains (varsInfo_, vid));
2011-12-12 15:29:51 +00:00
return varsInfo_.find (vid)->second;
}
2012-03-31 23:27:37 +01:00
2011-12-12 15:29:51 +00:00
static bool variablesHaveInformation (void)
{
return varsInfo_.size() != 0;
}
2012-03-31 23:27:37 +01:00
2011-12-12 15:29:51 +00:00
static void clearVariablesInformation (void)
{
varsInfo_.clear();
}
private:
2012-03-31 23:27:37 +01:00
static unordered_map<VarId,VarInfo> varsInfo_;
};
2011-12-12 15:29:51 +00:00
#endif // HORUS_GRAPHICALMODEL_H