📄 potential.h.svn-base
字号:
#ifndef POTENTIAL_H#define POTENTIAL_H#include <numeric>#include <vector>#include <map>#include <list>#include <RandomVariable.h>#ifndef NDEBUG#include <iostream>#endif// ******************* Potential Declaration **************//// The goal of this class, as always, is to be as general as possible... We want to model Potentials as capable of containing functions, but also discrete arrays of numbers. One of the problems is that we may then lookup a potential value by passing in all values of corresponding variable, or, (for efficiency) we may pass the index of these values// As a Potential is always linked to variables (it seems), I think it is a good idea to include links to these variables (?)// Or not, and then, we would have to always look up in the graph...// For now the links are not present//The following class is the base class. It is an abstract class.class Potential{ public: // Constructor, destructor virtual ~Potential(); // Virtual functions, defined (interface) virtual double get_potential_value() const = 0; virtual void set_variable_value(const RandomVariable &) = 0; virtual Potential * clone(); // Debug methods #ifndef NDEBUG virtual void debug_display_state();#endif private: unsigned int number_of_variables;};// ******************* End of Potential Declaration **************//// ******************* ContinuousPotential Declaration **************//// This subclass doesn't add anything yet... maybe for the futureclass ContinuousPotential: public Potential{ public: ContinuousPotential(); ~ContinuousPotential(); // double get_potential_value() const; // void set_variable_value (unsigned int, double) = 0; // void add_potential(Potential *); };// ******************* End of ContinuousPotential Declaration **************//// ******************* GaussianPotential Declaration **************//class GaussianPotential: public ContinuousPotential{ private: double variance; unsigned int variable_1_index; unsigned int variable_2_index; double value_1; double value_2; public: // Constructors GaussianPotential (double); GaussianPotential (double, RandomVariable &, RandomVariable &); // Inherited virtual functions void set_variable_value (const RandomVariable &); double get_potential_value() const; // Normal functions double get_variance() const; double get_variable_mean(unsigned int) const; // Debugging functions #ifndef NDEBUG void debug_display_state();#endif // Deprecated functions void set_variable_value (const unsigned int, const double); // should be removed, but necessary now for efficiency in the Particle Filters};inline double GaussianPotential::get_variance() const{ return variance;}// ******************* End of GaussianPotential Declaration **************//// ******************* BernouilliPotential Declaration **************//class BernouilliPotential: public ContinuousPotential{ private: double parameter; double threshold; unsigned int value_discrete; double value_continuous; unsigned int discrete_variable_index; unsigned int continuous_variable_index; public: // Constructors, destructor BernouilliPotential (const RandomVariable &, const RandomVariable &); // first discrete, then continuous // Inherited virtual functions double get_potential_value() const; void set_variable_value (const RandomVariable &); // Normal methods void set_threshold (const double); // Debug methods #ifndef NDEBUG void debug_display_state();#endif};inline void BernouilliPotential::set_threshold (const double a){ threshold = a;}// ******************* End of BernouilliPotential Declaration **************//// ******************* ChainedSinglePotential Declaration **************//class ChainedSinglePotential: public ContinuousPotential{ private: std::list < Potential * > potential_lst; const unsigned int variable_index; public: // Constructor, destructor ChainedSinglePotential(const unsigned int); ~ChainedSinglePotential(); // Inherited virtual functions void set_variable_value(const RandomVariable & rv); double get_potential_value() const; // Normal functions void add_potential(Potential *); // Deprecated functions void set_variable_value(const unsigned int, const double); friend class ParticleFilterProposal;};// ******************* End of ChainedSinglePotential Declaration **************//#include <DiscretePotential.h>#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -