PaGMO  1.1.5
hypervolume.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_UTIL_HYPERVOLUME_H
26 #define PAGMO_UTIL_HYPERVOLUME_H
27 
28 #include <iostream>
29 #include <vector>
30 #include <cmath>
31 #include "../population.h"
32 #include "hv_algorithm/base.h"
33 
34 namespace pagmo { namespace util {
35 
36 // Forward declaration
38 
40 typedef boost::shared_ptr<hypervolume> hypervolume_ptr;
41 
43 
49 class __PAGMO_VISIBLE hypervolume
50 {
51 public:
52  hypervolume();
53  hypervolume(const hypervolume &);
54  hypervolume(const boost::shared_ptr<population>, const bool verify = true);
55  hypervolume(const std::vector<fitness_vector> &, const bool verify = true);
56 
57  double compute(const fitness_vector &, const hv_algorithm::base_ptr) const;
58  double compute(const fitness_vector &) const;
59 
60  double exclusive(const unsigned int, const fitness_vector &, const hv_algorithm::base_ptr) const;
61  double exclusive(const unsigned int, const fitness_vector &) const;
62 
63  unsigned int least_contributor(const fitness_vector &, const hv_algorithm::base_ptr) const;
64  unsigned int least_contributor(const fitness_vector &) const;
65 
66  unsigned int greatest_contributor(const fitness_vector &, const hv_algorithm::base_ptr) const;
67  unsigned int greatest_contributor(const fitness_vector &) const;
68 
69  std::vector<double> contributions(const fitness_vector &, const hv_algorithm::base_ptr) const;
70  std::vector<double> contributions(const fitness_vector &) const;
71 
72  static double get_expected_operations(const unsigned int n, const unsigned int d);
73 
74  void set_copy_points(const bool);
75  bool get_copy_points();
76  void set_verify(const bool);
77  bool get_verify();
78 
79  fitness_vector get_nadir_point(const double epsilon = 0.0) const;
80 
81  hypervolume_ptr clone() const;
82  const std::vector<fitness_vector> get_points() const;
83 
84 private:
85  hv_algorithm::base_ptr get_best_compute(const fitness_vector &) const;
86  hv_algorithm::base_ptr get_best_exclusive(const unsigned int, const fitness_vector &) const;
87  hv_algorithm::base_ptr get_best_contributions(const fitness_vector &) const;
88  void verify_after_construct() const;
89  void verify_before_compute(const fitness_vector &, const hv_algorithm::base_ptr) const;
90 
91  std::vector<fitness_vector> m_points;
92  bool m_copy_points;
93  bool m_verify;
94 
95 
96  friend class boost::serialization::access;
97  template <class Archive>
98  void serialize(Archive &ar, const unsigned int)
99  {
100  ar & m_points;
101  ar & m_copy_points;
102  ar & m_verify;
103  }
104 };
105 
106 }}
107 
108 BOOST_CLASS_EXPORT_KEY(pagmo::util::hypervolume)
109 
110 #endif
Root PaGMO namespace.
boost::shared_ptr< hypervolume > hypervolume_ptr
Alias for the shared pointer to a pagmo::util::hypervolume.
Definition: hypervolume.h:37
std::vector< double > fitness_vector
Fitness vector type.
Definition: types.h:42
boost::shared_ptr< base > base_ptr
Base hypervolume algorithm class.
Hypervolume class.
Definition: hypervolume.h:49