DMP_BBO library
MetaParametersLWPR.cpp
Go to the documentation of this file.
1 
24 #include <boost/serialization/export.hpp>
25 #include <boost/archive/text_iarchive.hpp>
26 #include <boost/archive/text_oarchive.hpp>
27 #include <boost/archive/xml_iarchive.hpp>
28 #include <boost/archive/xml_oarchive.hpp>
30 
33 
34 #include <boost/serialization/base_object.hpp>
35 #include <boost/serialization/nvp.hpp>
36 #include <boost/serialization/vector.hpp>
37 
38 #include <iostream>
39 
42 
43 using namespace Eigen;
44 using namespace std;
45 
46 namespace DmpBbo {
47 
48 MetaParametersLWPR::MetaParametersLWPR(
49  int expected_input_dim,
50  Eigen::VectorXd init_D, double w_gen, double w_prune,
51  bool update_D, double init_alpha, double penalty, bool diag_only,
52  bool use_meta, double meta_rate, std::string kernel_name
53  )
54 :
55  MetaParameters(expected_input_dim),
56  init_D_(init_D), w_gen_(w_gen), w_prune_(w_prune),
57  update_D_(update_D), init_alpha_(init_alpha), penalty_(penalty), diag_only_(diag_only),
58  use_meta_(use_meta), meta_rate_(meta_rate), kernel_name_(kernel_name)
59 {
60  assert(init_D_.size()==expected_input_dim);
61  assert(w_gen_>0.0 && w_gen_<1.0);
62  assert(w_prune_>0.0 && w_prune_<1.0);
63  assert(w_gen_<w_prune_);
64 }
65 
67 {
68  return new MetaParametersLWPR(
70  init_D_, w_gen_, w_prune_,
71  update_D_, init_alpha_, penalty_, diag_only_,
72  use_meta_, meta_rate_, kernel_name_
73  );
74 }
75 
76 string MetaParametersLWPR::toString(void) const {
77  RETURN_STRING_FROM_BOOST_SERIALIZATION_XML("MetaParametersLWPR");
78 }
79 
80 
81 template<class Archive>
82 void MetaParametersLWPR::serialize(Archive & ar, const unsigned int version)
83 {
84  // serialize base class information
85  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(MetaParameters);
86 
87  ar & BOOST_SERIALIZATION_NVP(init_D_);
88  ar & BOOST_SERIALIZATION_NVP(w_gen_);
89  ar & BOOST_SERIALIZATION_NVP(w_prune_);
90  ar & BOOST_SERIALIZATION_NVP(update_D_);
91  ar & BOOST_SERIALIZATION_NVP(init_alpha_);
92  ar & BOOST_SERIALIZATION_NVP(penalty_);
93  ar & BOOST_SERIALIZATION_NVP(diag_only_);
94  ar & BOOST_SERIALIZATION_NVP(use_meta_);
95  ar & BOOST_SERIALIZATION_NVP(meta_rate_);
96  ar & BOOST_SERIALIZATION_NVP(kernel_name_);
97 
98 }
99 
100 }
101 
int getExpectedInputDim(void) const
The expected dimensionality of the input data.
MetaParametersLWPR class header file.
#define RETURN_STRING_FROM_BOOST_SERIALIZATION_XML(name)
Macro to convert the boost XML serialization of an object into a string.
Base class for all meta-parameters of function approximators.
Header file to generate strings from boost serialized files.
Meta-parameters for the Locally Weighted Projection Regression (LWPR) function approximator.
std::string toString(void) const
Returns a string representation of the object.
MetaParametersLWPR * clone(void) const
Return a pointer to a deep copy of the MetaParameters object.
BOOST_CLASS_EXPORT_IMPLEMENT(DmpBbo::MetaParametersLWPR)
For boost::serialization.
Header file for serialization of Eigen matrices.