PaGMO  1.1.5
cstrs_immune_system.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_CSTRS_IMMUNE_SYSTEM_H
26 #define PAGMO_ALGORITHM_CSTRS_IMMUNE_SYSTEM_H
27 
28 #include <string>
29 
30 #include "../config.h"
31 #include "../population.h"
32 #include "../serialization.h"
33 #include "base.h"
34 #include "jde.h"
35 #include "sga.h"
36 
37 namespace pagmo { namespace algorithm {
38 
40 
57 class __PAGMO_VISIBLE cstrs_immune_system: public base
58 {
59 public:
61 
68  // Immune system antibody selection method: best antibody, infeasibility
69  enum select_method_type {BEST_ANTIBODY = 0, INFEASIBILITY = 1};
70 
72 
79  enum inject_method_type {CHAMPION = 0, BEST25 = 1};
80 
82 
85  // hamming distance, euclidean distance
86  enum distance_method_type {HAMMING = 0, EUCLIDEAN = 1};
87 
88  cstrs_immune_system(const base & = jde(1), const base & = sga(), int gen = 1,
89  select_method_type = BEST_ANTIBODY,
90  inject_method_type = CHAMPION,
91  distance_method_type = EUCLIDEAN,
92  double = 0.5,
93  double = 0.5,
94  double = 1./3.,
95  double = 1e-15, double = 1e-15);
97  base_ptr clone() const;
98 
99 public:
100  void evolve(population &) const;
101  std::string get_name() const;
102  base_ptr get_algorithm() const;
103  void set_algorithm(const base &);
104  base_ptr get_algorithm_immune() const;
105  void set_algorithm_immune(const base &);
106 
107 protected:
108  std::string human_readable_extra() const;
109 
110 private:
111  friend class boost::serialization::access;
112  template <class Archive>
113  void serialize(Archive &ar, const unsigned int)
114  {
115  ar & boost::serialization::base_object<base>(*this);
116  ar & m_original_algo;
117  ar & m_original_algo_immune;
118  ar & const_cast<int &>(m_gen);
119  ar & m_select_method;
120  ar & m_inject_method;
121  ar & m_distance_method;
122  ar & const_cast<double &>(m_phi);
123  ar & const_cast<double &>(m_gamma);
124  ar & const_cast<double &>(m_sigma);
125  ar & const_cast<double &>(m_ftol);
126  ar & const_cast<double &>(m_xtol);
127  }
128  base_ptr m_original_algo;
129  base_ptr m_original_algo_immune;
130  //Number of generations
131  const int m_gen;
132  // problem associated to population penalties variables
133  select_method_type m_select_method;
134  inject_method_type m_inject_method;
135  distance_method_type m_distance_method;
136  // algorithm constants
137  const double m_phi;
138  const double m_gamma;
139  const double m_sigma;
140  // tolerance
141  const double m_ftol;
142  const double m_xtol;
143 };
144 
145 }} //namespaces
146 
147 BOOST_CLASS_EXPORT_KEY(pagmo::algorithm::cstrs_immune_system)
148 
149 #endif // PAGMO_ALGORITHM_CSTRS_IMMUNE_SYSTEM_H
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base algorithm.
Root PaGMO namespace.
Immune system constraints handling meta-algorithm.
Base algorithm class.
Population class.
Definition: population.h:70
distance_method_type
Type of antibodies problem distance method.
select_method_type
Type of immune system antibody selection method.
inject_method_type
Type of immune system antibody injection method.
The Simple Genetic Algorithm (SGA)
Definition: sga.h:53
jDE - Differential Evolution Algorithm - Self-Adaptive C and R (2011)
Definition: jde.h:64