Direct Graphical Models  v.1.7.0
BaseRandomModel.h
1 // Base abstract class for random model training
2 // Written by Sergey G. Kosov in 2015 for Project X
3 #pragma once
4 
5 #include "types.h"
6 
7 namespace DirectGraphicalModels
8 {
14  RM_UNARY = 1,
17  };
18  // ================================ Base Random Model Class ================================
25  {
26  public:
31  CBaseRandomModel(byte nStates) : m_nStates(nStates) {}
32  virtual ~CBaseRandomModel(void) {}
33 
38  DllExport virtual void reset(void) = 0;
46  DllExport virtual void save(const std::string &path, const std::string &name = std::string(), short idx = -1) const;
54  DllExport virtual void load(const std::string &path, const std::string &name = std::string(), short idx = -1);
59  DllExport byte getNumStates(void) const { return m_nStates; }
60 
61 
62  protected:
68  DllExport virtual void saveFile(FILE *pFile) const = 0;
74  DllExport virtual void loadFile(FILE *pFile) = 0;
83  std::string generateFileName(const std::string &path, const std::string &name, short idx) const;
84 
85 
86  protected:
87  byte m_nStates;
88  };
89 }
Unary random model: no iteraction between nodes.
std::string generateFileName(const std::string &path, const std::string &name, short idx) const
Generates name of the data file for storing random model parameters.
RandomModelType
Random model types.
Base abstract class for random model training.
virtual void load(const std::string &path, const std::string &name=std::string(), short idx=-1)
Loads the training data.
CBaseRandomModel(byte nStates)
Constructor.
virtual void save(const std::string &path, const std::string &name=std::string(), short idx=-1) const
Saves the training data.
virtual void saveFile(FILE *pFile) const =0
Saves the random model into the file.
virtual void reset(void)=0
Resets class variables.
virtual void loadFile(FILE *pFile)=0
Loads the random model from the file.
byte getNumStates(void) const
Returns number of states (classes)
Pairwise random model: maximum two nodes in the cliques.
Triplet random model: maximum tree nodes in the cliques.
byte m_nStates
The number of states (classes)