DMP_BBO library
ModelParametersRRRFF.hpp
Go to the documentation of this file.
1 
24 #ifndef MODELPARAMETERSRRRFF_H
25 #define MODELPARAMETERSRRRFF_H
26 
27 #include <iosfwd>
28 
30 
31 namespace DmpBbo {
32 
38 {
39  friend class FunctionApproximatorRRRFF;
40 
41 public:
47  ModelParametersRRRFF(Eigen::VectorXd linear_models, Eigen::MatrixXd cosines_periodes, Eigen::VectorXd cosines_phase);
48 
49  int getExpectedInputDim(void) const;
50 
51  std::string toString(void) const;
52 
53  ModelParameters* clone(void) const;
54 
55  void getSelectableParameters(std::set<std::string>& selected_values_labels) const;
56  void getParameterVectorMask(const std::set<std::string> selected_values_labels, Eigen::VectorXi& selected_mask) const;
57  void getParameterVectorAll(Eigen::VectorXd& all_values) const;
58 
59  inline int getParameterVectorAllSize(void) const
60  {
61  return all_values_vector_size_;
62  }
63 
64  UnifiedModel* toUnifiedModel(void) const;
65 
69  const Eigen::VectorXd& weights(void) const { return weights_; }
70 
71 
76  void cosineActivations(const Eigen::Ref<const Eigen::MatrixXd>& inputs, Eigen::MatrixXd& cosine_activations) const;
77 
78 protected:
79  void setParameterVectorAll(const Eigen::VectorXd& values);
80 
81 private:
82 
83  Eigen::VectorXd weights_;
84  Eigen::MatrixXd cosines_periodes_;
85  Eigen::VectorXd cosines_phase_;
86 
87  int nb_in_dim_;
88 
89  int all_values_vector_size_;
90 
91 public:
99  inline void set_caching(bool caching)
100  {
101  caching_ = caching;
102  if (!caching_) clearCache();
103  }
104 
105 private:
106 
107  mutable Eigen::MatrixXd inputs_cached_;
108  mutable Eigen::MatrixXd cosine_activations_cached_;
109  bool caching_;
110  inline void clearCache(void)
111  {
112  inputs_cached_.resize(0,0);
113  cosine_activations_cached_.resize(0,0);
114  }
115 
123 
125  friend class boost::serialization::access;
126 
132  template<class Archive>
133  void serialize(Archive & ar, const unsigned int version);
134 
135 };
136 
137 }
138 
139 #include <boost/serialization/export.hpp>
142 
143 
144 BOOST_CLASS_IMPLEMENTATION(DmpBbo::ModelParametersRRRFF,boost::serialization::object_serializable);
145 
146 #endif // #ifndef MODELPARAMETERSRRRFF_H
147 
void getSelectableParameters(std::set< std::string > &selected_values_labels) const
Return all the names of the parameter types that can be selected.
std::string toString(void) const
Returns a string representation of the object.
void getParameterVectorMask(const std::set< std::string > selected_values_labels, Eigen::VectorXi &selected_mask) const
Get a mask for selecting parameters.
friend class boost::serialization::access
Give boost serialization access to private members.
ModelParameters * clone(void) const
Return a pointer to a deep copy of the ModelParameters object.
const Eigen::VectorXd & weights(void) const
Return the weights of the basis functions.
int getExpectedInputDim(void) const
The expected dimensionality of the input data.
BOOST_CLASS_EXPORT_KEY2(DmpBbo::TimeSystem,"TimeSystem")
Register this derived class.
BOOST_CLASS_IMPLEMENTATION(DmpBbo::ModelParametersRRRFF, boost::serialization::object_serializable)
Register this derived class.
UnifiedModel * toUnifiedModel(void) const
Convert these model parameters to unified model parameters.
The unified model, which can be used to represent the model of all other function approximators...
RRRFF (Ridge Regression with Random Fourier Features) function approximatorhttps://www.ncbi.nlm.nih.gov/pmc/articles/PMC3935121/.
ModelParameters class header file.
Base class for all model parameters of function approximators.
void setParameterVectorAll(const Eigen::VectorXd &values)
Set all available parameter values with one vector.
Model parameters for the RRRFF function approximator.
void getParameterVectorAll(Eigen::VectorXd &all_values) const
Return a vector that returns all available parameter values.
void set_caching(bool caching)
Turn caching for the function cosineActivations() on or off.
int getParameterVectorAllSize(void) const
Get the size of the parameter values vector when it contains all available parameter values...
void cosineActivations(const Eigen::Ref< const Eigen::MatrixXd > &inputs, Eigen::MatrixXd &cosine_activations) const
Get the values of the cosine basis functions for given inputs.