PaGMO  1.1.5
problem/cstrs_self_adaptive.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_PROBLEM_CSTRS_SELF_ADAPTIVE_H
26 #define PAGMO_PROBLEM_CSTRS_SELF_ADAPTIVE_H
27 
28 #include <string>
29 
30 #include "../serialization.h"
31 #include "../types.h"
32 #include "cec2006.h"
33 #include "base_meta.h"
34 
35 #include <boost/functional/hash.hpp>
36 #include <boost/serialization/map.hpp>
37 
40 
41 namespace pagmo{ namespace problem {
42 
44 
63 class __PAGMO_VISIBLE cstrs_self_adaptive : public base_meta
64 {
65 public:
66  //constructors
67  cstrs_self_adaptive(const base & = cec2006(4));
68  cstrs_self_adaptive(const base &, const population &);
69 
70  base_ptr clone() const;
71  std::string get_name() const;
72 
73  //update penalty and fitnesses with the population
74  void update_penalty_coeff(const population &pop);
75 
76 protected:
77  std::string human_readable_extra() const;
78  void objfun_impl(fitness_vector &, const decision_vector &) const;
79 
80 private:
81  void update_c_scaling(const population &pop);
82  double compute_solution_infeasibility(const constraint_vector &c) const;
83 
84 private:
85  friend class boost::serialization::access;
86  template <class Archive>
87  void serialize(Archive &ar, const unsigned int)
88  {
89  ar & boost::serialization::base_object<base_meta>(*this);
90  ar & const_cast<bool &>(m_apply_penalty_1);
91  ar & m_scaling_factor;
92  ar & m_c_scaling;
93  ar & m_f_hat_down;
94  ar & m_f_hat_up;
95  ar & m_f_hat_round;
96  ar & m_i_hat_down;
97  ar & m_i_hat_up;
98  ar & m_i_hat_round;
99  ar & m_map_fitness;
100  ar & m_map_constraint;
101  }
102 
103  bool m_apply_penalty_1;
104  double m_scaling_factor;
105 
106  constraint_vector m_c_scaling;
107 
108  fitness_vector m_f_hat_down;
109  fitness_vector m_f_hat_up;
110  fitness_vector m_f_hat_round;
111 
112  double m_i_hat_down;
113  double m_i_hat_up;
114  double m_i_hat_round;
115 
116  std::map<std::size_t, fitness_vector> m_map_fitness;
117  std::map<std::size_t, constraint_vector> m_map_constraint;
118 
119  // no need to serialize the hasher (and impossible)
120  boost::hash< std::vector<double> > m_decision_vector_hash;
121 };
122 }} //namespaces
123 
125 
126 BOOST_CLASS_EXPORT_KEY(pagmo::problem::cstrs_self_adaptive)
127 
128 #endif // PAGMO_PROBLEM_cstrs_self_adaptive_H
Root PaGMO namespace.
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base problem.
Definition: problem/base.h:62
std::vector< double > decision_vector
Decision vector type.
Definition: types.h:40
std::vector< double > fitness_vector
Fitness vector type.
Definition: types.h:42
std::vector< double > constraint_vector
Constraint vector type.
Definition: types.h:44