DMP_BBO library
Public Member Functions | Friends | List of all members

Meta-parameters for the Radial Basis Function Network (RBFN) function approximator. More...

#include <MetaParametersRBFN.hpp>

Inheritance diagram for MetaParametersRBFN:
Inheritance graph
[legend]
Collaboration diagram for MetaParametersRBFN:
Collaboration graph
[legend]

Public Member Functions

 MetaParametersRBFN (int expected_input_dim, const std::vector< Eigen::VectorXd > &centers_per_dim, double intersection_height=0.5, double regularization=0.0)
 Constructor for the algorithmic meta-parameters of the RBFN function approximator. More...
 
 MetaParametersRBFN (int expected_input_dim, const Eigen::VectorXi &n_basis_functions_per_dim, double intersection_height=0.5, double regularization=0.0)
 Constructor for the algorithmic meta-parameters of the RBFN function approximator. More...
 
 MetaParametersRBFN (int expected_input_dim, int n_basis_functions=10, double intersection_height=0.5, double regularization=0.0)
 Constructor for the algorithmic meta-parameters of the RBFN function approximator. More...
 
double regularization (void) const
 Accessor function for regularization. More...
 
void getCentersAndWidths (const Eigen::VectorXd &min, const Eigen::VectorXd &max, Eigen::MatrixXd &centers, Eigen::MatrixXd &widths) const
 Get the centers and widths of the basis functions. More...
 
MetaParametersRBFNclone (void) const
 Return a pointer to a deep copy of the MetaParameters object. More...
 
std::string toString (void) const
 Returns a string representation of the object. More...
 
- Public Member Functions inherited from MetaParameters
 MetaParameters (int expected_input_dim)
 Constructor. More...
 
virtual ~MetaParameters (void)
 Virtual destructor, because this is a base class.
 
int getExpectedInputDim (void) const
 The expected dimensionality of the input data. More...
 
virtual int getExpectedOutputDim (void) const
 The expected dimensionality of the output data. More...
 

Friends

class boost::serialization::access
 Give boost serialization access to private members. More...
 

Additional Inherited Members

- Protected Member Functions inherited from MetaParameters
 MetaParameters (void)
 Default constructor. More...
 

Detailed Description

Meta-parameters for the Radial Basis Function Network (RBFN) function approximator.

Definition at line 39 of file MetaParametersRBFN.hpp.

Constructor & Destructor Documentation

MetaParametersRBFN ( int  expected_input_dim,
const std::vector< Eigen::VectorXd > &  centers_per_dim,
double  intersection_height = 0.5,
double  regularization = 0.0 
)

Constructor for the algorithmic meta-parameters of the RBFN function approximator.

Parameters
[in]expected_input_dimThe dimensionality of the data this function approximator expects. Although this information is already contained in the 'centers_per_dim' argument, we ask the user to pass it explicitly so that various checks on the arguments may be conducted.
[in]centers_per_dimCenters of the basis functions, one VectorXd for each dimension.
[in]intersection_heightThe value at which two neighbouring basis functions will intersect.
[in]regularizationRegularization parameter

Definition at line 52 of file MetaParametersRBFN.cpp.

53 :
54  MetaParameters(expected_input_dim),
55  n_bfs_per_dim_(VectorXi::Zero(0)),
56  centers_per_dim_(centers_per_dim),
57  intersection_height_(intersection_height),
58  regularization_(regularization)
59 {
60  assert(expected_input_dim==(int)centers_per_dim_.size());
61  for (unsigned int dd=0; dd<centers_per_dim_.size(); dd++)
62  assert(centers_per_dim_[dd].size()>0);
63  assert(intersection_height_>0 && intersection_height_<1);
64  assert(regularization>=0.0);
65 }
double regularization(void) const
Accessor function for regularization.
MetaParameters(void)
Default constructor.
MetaParametersRBFN ( int  expected_input_dim,
const Eigen::VectorXi &  n_basis_functions_per_dim,
double  intersection_height = 0.5,
double  regularization = 0.0 
)

Constructor for the algorithmic meta-parameters of the RBFN function approximator.

Parameters
[in]expected_input_dimThe dimensionality of the data this function approximator expects. Although this information is already contained in the 'centers' argument, we ask the user to pass it explicitly so that various checks on the arguments may be conducted.
[in]n_basis_functions_per_dimNumber of basis functions
[in]intersection_heightThe value at which two neighbouring basis functions will intersect.
[in]regularizationRegularization parameter

The centers and widths of the basis functions are determined from these parameters once the range of the input data is known, see also setInputMinMax()

Definition at line 67 of file MetaParametersRBFN.cpp.

68 :
69  MetaParameters(expected_input_dim),
70  n_bfs_per_dim_(n_bfs_per_dim),
71  centers_per_dim_(std::vector<Eigen::VectorXd>(0)),
72  intersection_height_(intersection_height),
73  regularization_(regularization)
74 {
75  assert(expected_input_dim==n_bfs_per_dim_.size());
76  for (int dd=0; dd<n_bfs_per_dim_.size(); dd++)
77  assert(n_bfs_per_dim_[dd]>0);
78  assert(intersection_height_>0 && intersection_height_<1);
79  assert(regularization>=0.0);
80 };
double regularization(void) const
Accessor function for regularization.
MetaParameters(void)
Default constructor.
MetaParametersRBFN ( int  expected_input_dim,
int  n_basis_functions = 10,
double  intersection_height = 0.5,
double  regularization = 0.0 
)

Constructor for the algorithmic meta-parameters of the RBFN function approximator.

This is for the special case when the dimensionality of the input data is 1.

Parameters
[in]expected_input_dimThe dimensionality of the data this function approximator expects. Since this constructor is for 1-D input data only, we simply check if this argument is equal to 1.
[in]n_basis_functionsNumber of basis functions for the one dimension
[in]intersection_heightThe value at which two neighbouring basis functions will intersect.
[in]regularizationRegularization parameter

The centers and widths of the basis functions are determined from these parameters once the range of the input data is known, see also setInputMinMax()

Definition at line 82 of file MetaParametersRBFN.cpp.

83 :
84  MetaParameters(expected_input_dim),
85  n_bfs_per_dim_(VectorXi::Constant(1,n_bfs)),
86  centers_per_dim_(std::vector<Eigen::VectorXd>(0)),
87  intersection_height_(intersection_height),
88  regularization_(regularization)
89 {
90  assert(expected_input_dim==n_bfs_per_dim_.size());
91  for (int dd=0; dd<n_bfs_per_dim_.size(); dd++)
92  assert(n_bfs_per_dim_[dd]>0);
93  assert(intersection_height_>0 && intersection_height_<1);
94  assert(regularization>=0.0);
95 };
double regularization(void) const
Accessor function for regularization.
MetaParameters(void)
Default constructor.

Member Function Documentation

double regularization ( void  ) const
inline

Accessor function for regularization.

Returns
Regularization parameter.

Definition at line 79 of file MetaParametersRBFN.hpp.

80  {
81  return regularization_;
82  }

Here is the call graph for this function:

void getCentersAndWidths ( const Eigen::VectorXd &  min,
const Eigen::VectorXd &  max,
Eigen::MatrixXd &  centers,
Eigen::MatrixXd &  widths 
) const

Get the centers and widths of the basis functions.

Parameters
[in]minMinimum values of input data (one value for each dimension).
[in]maxMaximum values of input data (one value for each dimension).
[out]centersCenters of the basis functions (matrix of size n_basis_functions X n_input_dims
[out]widthsWidths of the basis functions (matrix of size n_basis_functions X n_input_dims

The reason why there are not two functions getCenters and getWidths is that it is much easier to compute both at the same time, and usually you will need both at the same time anyway.

Todo:
Document this rather complex function

Definition at line 109 of file MetaParametersRBFN.cpp.

110 {
111  int n_dims = getExpectedInputDim();
112  assert(min.size()==n_dims);
113  assert(max.size()==n_dims);
114 
115  vector<VectorXd> centers_per_dim_local(n_dims);
116  if (!centers_per_dim_.empty())
117  {
118  centers_per_dim_local = centers_per_dim_;
119  }
120  else
121  {
122  // Centers are not know yet, compute them based on min and max
123  for (int i_dim=0; i_dim<n_dims; i_dim++)
124  centers_per_dim_local[i_dim] = VectorXd::LinSpaced(n_bfs_per_dim_[i_dim],min[i_dim],max[i_dim]);
125  }
126 
127  // Determine the widths from the centers (separately for each dimension)
128  vector<VectorXd> widths_per_dim_local(n_dims);
129  for (int i_dim=0; i_dim<n_dims; i_dim++)
130  {
131  VectorXd cur_centers = centers_per_dim_local[i_dim]; // Abbreviation for convenience
132  int n_centers = cur_centers.size();
133  VectorXd cur_widths(n_centers);
134 
135  if (n_centers==1)
136  {
137  cur_widths[0] = 1.0;
138  }
139  else
140  {
141  // Consider two neighbouring basis functions, exp(-0.5(x-c0)^2/w^2) and exp(-0.5(x-c1)^2/w^2)
142  // Assuming the widths are the same for both, they are certain to intersect at x = 0.5(c0+c1)
143  // And we want the activation at x to be 'intersection'. So
144  // y = exp(-0.5(x-c0)^2/w^2)
145  // intersection = exp(-0.5((0.5(c0+c1))-c0)^2/w^2)
146  // intersection = exp(-0.5((0.5*c1-0.5*c0)^2/w^2))
147  // intersection = exp(-0.5((0.5*(c1-c0))^2/w^2))
148  // intersection = exp(-0.5(0.25*(c1-c0)^2/w^2))
149  // intersection = exp(-0.125((c1-c0)^2/w^2))
150  // w = sqrt((c1-c0)^2/-8*ln(intersection))
151  for (int cc=0; cc<n_centers-1; cc++)
152  {
153  double w = sqrt(pow(cur_centers[cc+1]-cur_centers[cc],2)/(-8*log(intersection_height_)));
154  cur_widths[cc] = w;
155  }
156  cur_widths[n_centers-1] = cur_widths[n_centers-2];
157  }
158  widths_per_dim_local[i_dim] = cur_widths;
159  }
160 
161  VectorXd digit_max(n_dims);
162  int n_centers = 1;
163  for (int i_dim=0; i_dim<n_dims; i_dim++)
164  {
165  n_centers = n_centers*centers_per_dim_local[i_dim].size();
166  digit_max[i_dim] = centers_per_dim_local[i_dim].size();
167  }
168  VectorXi digit = VectorXi::Zero(n_dims);
169 
170  centers.resize(n_centers,n_dims);
171  widths.resize(n_centers,n_dims);
172  int i_center=0;
173 
174  while (digit[0]<digit_max(0))
175  {
176  for (int i_dim=0; i_dim<n_dims; i_dim++)
177  {
178  centers(i_center,i_dim) = centers_per_dim_local[i_dim][digit[i_dim]];
179  widths(i_center,i_dim) = widths_per_dim_local[i_dim][digit[i_dim]];
180  }
181  i_center++;
182 
183  // Increment last digit by one
184  digit[n_dims-1]++;
185  for (int i_dim=n_dims-1; i_dim>0; i_dim--)
186  {
187  if (digit[i_dim]>=digit_max[i_dim])
188  {
189  digit[i_dim] = 0;
190  digit[i_dim-1]++;
191  }
192  }
193  }
194 
195 }
int getExpectedInputDim(void) const
The expected dimensionality of the input data.

Here is the call graph for this function:

MetaParametersRBFN * clone ( void  ) const
virtual

Return a pointer to a deep copy of the MetaParameters object.

Returns
Pointer to a deep copy

Implements MetaParameters.

Definition at line 97 of file MetaParametersRBFN.cpp.

98 {
99  MetaParametersRBFN* cloned;
100  if (centers_per_dim_.size()>0)
101  cloned = new MetaParametersRBFN(getExpectedInputDim(),centers_per_dim_,intersection_height_,regularization_);
102  else
103  cloned = new MetaParametersRBFN(getExpectedInputDim(),n_bfs_per_dim_,intersection_height_,regularization_);
104 
105  return cloned;
106 }
int getExpectedInputDim(void) const
The expected dimensionality of the input data.
MetaParametersRBFN(int expected_input_dim, const std::vector< Eigen::VectorXd > &centers_per_dim, double intersection_height=0.5, double regularization=0.0)
Constructor for the algorithmic meta-parameters of the RBFN function approximator.

Here is the call graph for this function:

string toString ( void  ) const
virtual

Returns a string representation of the object.

Returns
A string representation of the object.

Implements MetaParameters.

Definition at line 209 of file MetaParametersRBFN.cpp.

210 {
211  RETURN_STRING_FROM_BOOST_SERIALIZATION_XML("MetaParametersRBFN");
212 }
#define RETURN_STRING_FROM_BOOST_SERIALIZATION_XML(name)
Macro to convert the boost XML serialization of an object into a string.

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Give boost serialization access to private members.

Definition at line 111 of file MetaParametersRBFN.hpp.


The documentation for this class was generated from the following files: