PaGMO  1.1.5
wfg.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_HV_ALGORITHM_WFG_H
26 #define PAGMO_UTIL_HV_ALGORITHM_WFG_H
27 
28 #include <iostream>
29 #include <vector>
30 #include <cmath>
31 #include <algorithm>
32 #include <iterator>
33 
34 #include "base.h"
35 #include "../hypervolume.h"
36 
37 namespace pagmo { namespace util { namespace hv_algorithm {
38 
40 
48 class __PAGMO_VISIBLE wfg : public base
49 {
50 public:
51  wfg(const unsigned int stop_dimension = 2);
52  double compute(std::vector<fitness_vector> &, const fitness_vector &) const;
53  std::vector<double> contributions(std::vector<fitness_vector> &, const fitness_vector &) const;
54  void verify_before_compute(const std::vector<fitness_vector> &, const fitness_vector &) const;
55  base_ptr clone() const;
56  std::string get_name() const;
57 
58 private:
59  void limitset(const unsigned int, const unsigned int, const unsigned int) const;
60  double exclusive_hv(const unsigned int, const unsigned int) const;
61  double compute_hv(const unsigned int) const;
62 
63  bool cmp_points(double* a, double* b) const;
64 
65  void allocate_wfg_members(std::vector<fitness_vector> &, const fitness_vector &) const;
66  void free_wfg_members() const;
67 
76  // Current slice depth
77  mutable unsigned int m_current_slice;
78 
79  // Array of point sets for each recursive level.
80  mutable double*** m_frames;
81 
82  // Maintains the number of points at given recursion level.
83  mutable unsigned int* m_frames_size;
84 
85  // Keeps track of currently allocated number of frames.
86  mutable unsigned int m_n_frames;
87 
88  // Copy of the reference point
89  mutable double* m_refpoint;
90 
91  // Size of the original front
92  mutable unsigned int m_max_points;
93 
94  // Size of the dimension
95  mutable unsigned int m_max_dim;
100  // Dimension at which WFG stops the slicing
101  const unsigned int m_stop_dimension;
102 
103  friend class boost::serialization::access;
104  template <class Archive>
105  void serialize(Archive &ar, const unsigned int)
106  {
107  ar & boost::serialization::base_object<base>(*this);
108  ar & const_cast<unsigned int &>(m_stop_dimension);
109  }
110 };
111 
112 } } }
113 
114 BOOST_CLASS_EXPORT_KEY(pagmo::util::hv_algorithm::wfg)
115 
116 #endif
Root PaGMO namespace.
WFG hypervolume algorithm.
Definition: wfg.h:48
std::vector< double > fitness_vector
Fitness vector type.
Definition: types.h:42
boost::shared_ptr< base > base_ptr
Base hypervolume algorithm class.