PaGMO  1.1.5
ihs.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_IHS_H
26 #define PAGMO_ALGORITHM_IHS_H
27 
28 #include <cstddef>
29 #include <iostream>
30 #include <string>
31 
32 #include "../config.h"
33 #include "../population.h"
34 #include "../serialization.h"
35 #include "../types.h"
36 #include "base.h"
37 
38 namespace pagmo { namespace algorithm {
39 
40 // TODO: automatic reshuffling when the population becomes too homogeneous.
42 
62 class __PAGMO_VISIBLE ihs: public base
63 {
64  public:
65  ihs(int gen = 1, const double &phmcr = 0.85, const double &ppar_min = 0.35, const double &ppar_max = 0.99,
66  const double &bw_min = 1E-5, const double &bw_max = 1);
67  base_ptr clone() const;
68  void evolve(population &) const;
69  std::string get_name() const;
70  protected:
71  std::string human_readable_extra() const;
72  private:
73  friend class boost::serialization::access;
74  template <class Archive>
75  void serialize(Archive &ar, const unsigned int)
76  {
77  ar & boost::serialization::base_object<base>(*this);
78  ar & const_cast<std::size_t &>(m_gen);
79  ar & const_cast<double &>(m_phmcr);
80  ar & const_cast<double &>(m_ppar_min);
81  ar & const_cast<double &>(m_ppar_max);
82  ar & const_cast<double &>(m_bw_min);
83  ar & const_cast<double &>(m_bw_max);
84  }
85  // Number of generations.
86  const std::size_t m_gen;
87  // Rate of choosing from memory (i.e., from population).
88  const double m_phmcr;
89  // Minimum pitch adjustment rate.
90  const double m_ppar_min;
91  // Maximum pitch adjustment rate.
92  const double m_ppar_max;
93  // Mininum distance bandwidth.
94  const double m_bw_min;
95  // Maximum distance bandwidth.
96  const double m_bw_max;
97 };
98 
99 }} //namespaces
100 
101 BOOST_CLASS_EXPORT_KEY(pagmo::algorithm::ihs)
102 
103 #endif
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
Improved harmony search algorithm.
Definition: ihs.h:62