DMP_BBO library
ModelParametersRBFN.hpp
Go to the documentation of this file.
1 
24 #ifndef MODELPARAMETERSRBFN_H
25 #define MODELPARAMETERSRBFN_H
26 
28 
29 #include <iosfwd>
30 #include <vector>
31 
32 #include <eigen3/Eigen/Core>
33 
34 namespace DmpBbo {
35 
36  // Forward declaration
37 class UnifiedModel;
38 
39 
45 {
46  friend class FunctionApproximatorRBFN;
47 
48 public:
54  ModelParametersRBFN(const Eigen::MatrixXd& centers, const Eigen::MatrixXd& widths, const Eigen::MatrixXd& weights);
55 
56  std::string toString(void) const;
57 
58  ModelParameters* clone(void) const;
59 
60  int getExpectedInputDim(void) const {
61  return centers_.cols();
62  };
63 
67  inline unsigned int getNumberOfBasisFunctions() const
68  {
69  return centers_.rows();
70  }
71 
76  void kernelActivations(const Eigen::Ref<const Eigen::MatrixXd>& inputs, Eigen::MatrixXd& kernel_activations) const;
77 
78  void setParameterVectorModifierPrivate(std::string modifier, bool new_value);
79 
80  void getSelectableParameters(std::set<std::string>& selected_values_labels) const;
81  void getParameterVectorMask(const std::set<std::string> selected_values_labels, Eigen::VectorXi& selected_mask) const;
82  void getParameterVectorAll(Eigen::VectorXd& all_values) const;
83  inline int getParameterVectorAllSize(void) const
84  {
85  return all_values_vector_size_;
86  }
87 
91  const Eigen::VectorXd& weights(void) const { return weights_; }
92 
96  inline void weights(Eigen::VectorXd& weights) const { weights=weights_; }
97 
98 protected:
99  void setParameterVectorAll(const Eigen::VectorXd& values);
100 
101 private:
102  Eigen::MatrixXd centers_; // n_centers X n_dims
103  Eigen::MatrixXd widths_; // n_centers X n_dims
104  Eigen::VectorXd weights_; // 1 X n_dims
105 
106  int all_values_vector_size_;
107 
108 public:
116  inline void set_caching(bool caching)
117  {
118  caching_ = caching;
119  if (!caching_) clearCache();
120  }
121 
122  UnifiedModel* toUnifiedModel(void) const;
123 
124 private:
125 
126  mutable Eigen::MatrixXd inputs_cached_;
127  mutable Eigen::MatrixXd kernel_activations_cached_;
128  bool caching_;
129  inline void clearCache(void)
130  {
131  inputs_cached_.resize(0,0);
132  kernel_activations_cached_.resize(0,0);
133  }
134 
142 
143 
145  friend class boost::serialization::access;
146 
152  template<class Archive>
153  void serialize(Archive & ar, const unsigned int version);
154 
155 };
156 
157 }
158 
159 #include <boost/serialization/export.hpp>
162 
163 
164 BOOST_CLASS_IMPLEMENTATION(DmpBbo::ModelParametersRBFN,boost::serialization::object_serializable);
165 
166 #endif // #ifndef MODELPARAMETERSRBFN_H
167 
BOOST_CLASS_IMPLEMENTATION(DmpBbo::ModelParametersRBFN, boost::serialization::object_serializable)
Register this derived class.
int getExpectedInputDim(void) const
The expected dimensionality of the input data.
UnifiedModel * toUnifiedModel(void) const
Convert these model parameters to unified model parameters.
RBFN (Radial Basis Function Network) function approximator.
void kernelActivations(const Eigen::Ref< const Eigen::MatrixXd > &inputs, Eigen::MatrixXd &kernel_activations) const
Get the kernel activations for given inputs.
void set_caching(bool caching)
Turn caching for the function kernelActivations() on or off.
ModelParameters * clone(void) const
Return a pointer to a deep copy of the ModelParameters object.
BOOST_CLASS_EXPORT_KEY2(DmpBbo::TimeSystem,"TimeSystem")
Register this derived class.
int getParameterVectorAllSize(void) const
Get the size of the parameter values vector when it contains all available parameter values...
const Eigen::VectorXd & weights(void) const
Return the weights of the basis functions.
std::string toString(void) const
Returns a string representation of the object.
friend class boost::serialization::access
Give boost serialization access to private members.
The unified model, which can be used to represent the model of all other function approximators...
ModelParameters class header file.
void setParameterVectorAll(const Eigen::VectorXd &values)
Set all available parameter values with one vector.
void getParameterVectorAll(Eigen::VectorXd &all_values) const
Return a vector that returns all available parameter values.
Base class for all model parameters of function approximators.
void setParameterVectorModifierPrivate(std::string modifier, bool new_value)
Turn certain modifiers on or off, see Parameterizable::setParameterVectorModifier().
Model parameters for the Radial Basis Function Network (RBFN) function approximator.
void weights(Eigen::VectorXd &weights) const
Return the weights of the basis functions.
unsigned int getNumberOfBasisFunctions() const
Get the number of basis functions in this model.
void getParameterVectorMask(const std::set< std::string > selected_values_labels, Eigen::VectorXi &selected_mask) const
Get a mask for selecting parameters.
void getSelectableParameters(std::set< std::string > &selected_values_labels) const
Return all the names of the parameter types that can be selected.