PaGMO  1.1.5
cmaes.h
1 /*****************************************************************************
2  * Copyright (C) 2004-2015 The PaGMO development team, *
3  * Advanced Concepts Team (ACT), European Space Agency (ESA) *
4  * *
5  * https://github.com/esa/pagmo *
6  * *
7  * act@esa.int *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the *
21  * Free Software Foundation, Inc., *
22  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23  *****************************************************************************/
24 
25 #ifndef PAGMO_ALGORITHM_CMAES_H
26 #define PAGMO_ALGORITHM_CMAES_H
27 
28 #include <string>
29 
30 
31 #include "../config.h"
32 #include "base.h"
33 #include "../population.h"
34 #include "../types.h"
35 #include "../serialization.h"
36 #include "../Eigen/Dense"
37 
38 
39 
40 
41 namespace pagmo { namespace algorithm {
42 
44 
48 class __PAGMO_VISIBLE cmaes: public base
49 {
50 public:
51  cmaes(int gen = 500, double cc = -1, double cs = -1, double c1 = -1, double cmu = -1, double sigma0=0.5, double ftol = 1e-6, double xtol = 1e-6, bool memory = true);
52  base_ptr clone() const;
53  void evolve(population &) const;
54  std::string get_name() const;
55 
56  // Setters and Getters (needed for all if we fine control the iterations .... )
57  void set_gen(const int gen);
58  int get_gen() const;
59 
60  void set_cc(const double p);
61  double get_cc() const;
62 
63  void set_cs(const double p);
64  double get_cs() const;
65 
66  void set_c1(const double p);
67  double get_c1() const;
68 
69  void set_cmu(const double p);
70  double get_cmu() const;
71 
72  void set_sigma(const double p);
73  double get_sigma() const;
74 
75  void set_xtol(const double p);
76  double get_xtol() const;
77 
78  void set_ftol(const double p);
79  double get_ftol() const;
80 
81 protected:
82  std::string human_readable_extra() const;
83 private:
84  friend class boost::serialization::access;
85  template <class Archive>
86  void serialize(Archive &ar, const unsigned int)
87  {
88  ar & boost::serialization::base_object<base>(*this);
89  ar & const_cast<std::size_t &>(m_gen);
90  ar & m_cc;
91  ar & m_cs;
92  ar & m_c1;
93  ar & m_cmu;
94  ar & m_sigma;
95  ar & m_xtol;
96  ar & m_ftol;
97  ar & m_memory;
98  ar & m_mean;
99  ar & m_variation;
100  ar & m_newpop;
101  ar & m_B;
102  ar & m_D;
103  ar & m_C;
104  ar & m_invsqrtC;
105  ar & m_pc;
106  ar & m_ps;
107  ar & m_counteval;
108  ar & m_eigeneval;
109  }
110  // "Real" data members
111  std::size_t m_gen;
112  double m_cc;
113  double m_cs;
114  double m_c1;
115  double m_cmu;
116  mutable double m_sigma;
117  double m_ftol;
118  double m_xtol;
119  bool m_memory;
120 
121  // "Memory" data members (these are here as to enable control over each single generation)
122  mutable Eigen::VectorXd m_mean;
123  mutable Eigen::VectorXd m_variation;
124  mutable std::vector<Eigen::VectorXd> m_newpop;
125  mutable Eigen::MatrixXd m_B;
126  mutable Eigen::MatrixXd m_D;
127  mutable Eigen::MatrixXd m_C;
128  mutable Eigen::MatrixXd m_invsqrtC;
129  mutable Eigen::VectorXd m_pc;
130  mutable Eigen::VectorXd m_ps;
131  mutable int m_counteval;
132  mutable int m_eigeneval;
133 };
134 
135 }} //namespaces
136 
137 BOOST_CLASS_EXPORT_KEY(pagmo::algorithm::cmaes)
138 
139 #endif // PAGMO_ALGORITHM_CMAES_H
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base algorithm.
Root PaGMO namespace.
Base algorithm class.
Population class.
Definition: population.h:70
Covariance Matrix Adaptation Evolutionary Strategy (CMAES)
Definition: cmaes.h:48
The Compass Search Solver (CS)
Definition: cs.h:63