PaGMO  1.1.5
fpl.cpp
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 
26 #include "fpl.h"
27 
28 namespace pagmo { namespace util { namespace hv_algorithm {
29 
31 
37 double fpl::compute(std::vector<fitness_vector> &points, const fitness_vector &r_point) const
38 {
39  // Prepare the initial data to suit the signature of the function 'fpli_hv'
40  unsigned int fdim = points[0].size();
41  std::vector<double> data;
42  data.reserve(points.size() * fdim);
43  for (unsigned int p_idx = 0 ; p_idx < points.size() ; ++p_idx) {
44  for (unsigned int d_idx = 0 ; d_idx < fdim ; ++d_idx) {
45  data.push_back(points[p_idx][d_idx]);
46  }
47  }
48 
49  double hv = fpli_hv(&data[0], fdim, points.size(), &r_point[0]);
50  return hv;
51 }
52 
54 
62 void fpl::verify_before_compute(const std::vector<fitness_vector> &points, const fitness_vector &r_point) const
63 {
64  base::assert_minimisation(points, r_point);
65 }
66 
69 {
70  return base_ptr(new fpl(*this));
71 }
72 
74 std::string fpl::get_name() const
75 {
76  return "FPL algorithm";
77 }
78 
79 } } }
80 
81 BOOST_CLASS_EXPORT_IMPLEMENT(pagmo::util::hv_algorithm::fpl)
Root PaGMO namespace.
void assert_minimisation(const std::vector< fitness_vector > &, const fitness_vector &) const
Assert that reference point dominates every other point from the set.
fpl hypervolume algorithm
Definition: fpl.h:56
std::vector< double > fitness_vector
Fitness vector type.
Definition: types.h:42
boost::shared_ptr< base > base_ptr
Base hypervolume algorithm class.
double compute(std::vector< fitness_vector > &, const fitness_vector &) const
Compute hypervolume.
Definition: fpl.cpp:37
base_ptr clone() const
Clone method.
Definition: fpl.cpp:68
void verify_before_compute(const std::vector< fitness_vector > &, const fitness_vector &) const
Verify before compute.
Definition: fpl.cpp:62
std::string get_name() const
Algorithm name.
Definition: fpl.cpp:74