PaGMO  1.1.5
antibodies_problem.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_ANTIBODIES_PROBLEM_H
26 #define PAGMO_PROBLEM_ANTIBODIES_PROBLEM_H
27 
28 #include <string>
29 #include <boost/functional/hash.hpp>
30 #include <boost/serialization/map.hpp>
31 
32 #include "../serialization.h"
33 #include "../types.h"
34 #include "cec2006.h"
35 #include "base.h"
36 #include "../algorithm/cstrs_immune_system.h"
37 
38 namespace pagmo{ namespace problem {
39 
41 
54 class __PAGMO_VISIBLE antibodies_problem : public base
55 {
56 //public:
57 // // hamming distance, euclidean distance
58 // enum method_type {HAMMING = 0, EUCLIDEAN = 1};
59 
60 public:
61  //constructors
62  antibodies_problem(const base & = cec2006(4), const algorithm::cstrs_immune_system::distance_method_type = algorithm::cstrs_immune_system::HAMMING);
63 
64  //copy constructor
66  base_ptr clone() const;
67  std::string get_name() const;
68 
69  void set_antigens(const std::vector<decision_vector> &);
70 
71 protected:
72  std::string human_readable_extra() const;
73  void objfun_impl(fitness_vector &, const decision_vector &) const;
74  bool compare_fitness_impl(const fitness_vector &, const fitness_vector &) const;
75 
76 private:
77  friend class boost::serialization::access;
78  template <class Archive>
79  void serialize(Archive &ar, const unsigned int)
80  {
81  ar & boost::serialization::base_object<base>(*this);
82  ar & m_original_problem;
83  ar & m_pop_antigens;
84  ar & const_cast<algorithm::cstrs_immune_system::distance_method_type &>(m_method);
85  ar & m_bit_encoding;
86  ar & m_max_encoding_integer;
87  }
88 
89  base_ptr m_original_problem;
90  std::vector<decision_vector> m_pop_antigens;
91 
93 
94  // encoding size
95  int m_bit_encoding;
96  int m_max_encoding_integer;
97 
98  // function to compute the distance
99  double compute_distance(const decision_vector &x) const;
100 
101  // function for the hamming distance
102  std::vector<int> double_to_binary(const double &number, const double &lb, const double &ub) const;
103 
104 };
105 
106 }} //namespaces
107 
108 BOOST_CLASS_EXPORT_KEY(pagmo::problem::antibodies_problem)
109 
110 #endif // PAGMO_PROBLEM_antibodies_problem_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
Base problem class.
Definition: problem/base.h:148
distance_method_type
Type of antibodies problem distance method.
The CEC 2006 problems: Constrained Real-Parameter Optimization.
Definition: cec2006.h:49
std::vector< double > fitness_vector
Fitness vector type.
Definition: types.h:42