PaGMO  1.1.5
vega.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_VEGA_H
26 #define PAGMO_ALGORITHM_VEGA_H
27 
28 #include <string>
29 
30 #include "../config.h"
31 #include "../population.h"
32 #include "../serialization.h"
33 #include "base.h"
34 
35 namespace pagmo { namespace algorithm {
36 
38 
51 class __PAGMO_VISIBLE vega: public base
52 {
53 public:
55  struct mutation {
57  enum type {GAUSSIAN = 0, RANDOM = 1};
59 
65  mutation(mutation::type t, double width) : m_type(t),m_width(width) {}
69  double m_width;
70  private:
71  friend class boost::serialization::access;
72  template <class Archive>
73  void serialize(Archive &ar, const unsigned int)
74  {
75  ar & m_type;
76  ar & m_width;
77  }
78  };
79 
81  struct crossover {
83  enum type {BINOMIAL = 0, EXPONENTIAL = 1};
84  };
85 
86 public:
87  // constructors
88  vega(int gen = 1, const double &cr = .95, const double &m = .02, int elitism = 1,
89  mutation::type mut = mutation::GAUSSIAN, double width = 0.1,
90  crossover::type cro = crossover::EXPONENTIAL);
91 
92  base_ptr clone() const;
93  std::string get_name() const;
94 
95  void evolve(population &) const;
96 
97 protected:
98  std::string human_readable_extra() const;
99 private:
100  friend class boost::serialization::access;
101  template <class Archive>
102  void serialize(Archive &ar, const unsigned int)
103  {
104  ar & boost::serialization::base_object<base>(*this);
105  ar & const_cast<int &>(m_gen);
106  ar & const_cast<double &>(m_cr);
107  ar & const_cast<double &>(m_m);
108  ar & const_cast<int &>(m_elitism);
109  ar & const_cast<mutation &>(m_mut);
110  ar & const_cast<crossover::type &>(m_cro);
111  }
112 
113  //Number of generations
114  const int m_gen;
115  //Crossover rate
116  const double m_cr;
117  //Mutation rate
118  const double m_m;
119 
120  //Elitism (number of generations after which to reinsert the best)
121  const int m_elitism;
122  //Mutation
123  const mutation m_mut;
124  //Crossover_type
125  const crossover::type m_cro;
126 };
127 
128 }} //namespaces
129 
130 BOOST_CLASS_EXPORT_KEY(pagmo::algorithm::vega)
131 
132 #endif // PAGMO_ALGORITHM_VEGA_H
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base algorithm.
Root PaGMO namespace.
type m_type
Mutation type.
Definition: vega.h:67
Base algorithm class.
Population class.
Definition: population.h:70
VEGA based multi-objective algorithm.
Definition: vega.h:51
type
Mutation type, gaussian or random.
Definition: vega.h:57
Crossover operator info.
Definition: vega.h:81
mutation(mutation::type t, double width)
Constructor.
Definition: vega.h:65
Mutation operator info.
Definition: vega.h:55
double m_width
Mutation width.
Definition: vega.h:69
type
Crossover type, binomial or exponential.
Definition: vega.h:83