25 #ifndef PAGMO_UTIL_NEIGHBOURHOOD_H
26 #define PAGMO_UTIL_NEIGHBOURHOOD_H
32 #include <boost/shared_ptr.hpp>
34 #include "../config.h"
35 #include "../population.h"
36 #include "../exceptions.h"
38 namespace pagmo{
namespace util {
44 namespace neighbourhood {
46 template<
class T>
class __PAGMO_VISIBLE sorter {
48 sorter(
const std::vector<T> &v) : values(v) {}
49 bool operator()(
int a,
int b) {
return values[a] < values[b]; }
51 const std::vector<T> &values;
55 template<
class T> std::vector<population::size_type>
order(
const std::vector<T> &values)
57 std::vector<pagmo::population::size_type> rv(values.size());
59 for (std::vector<pagmo::population::size_type>::iterator i = rv.begin(); i != rv.end(); i++)
61 std::sort(rv.begin(), rv.end(), sorter<T>(values));
71 static void compute_neighbours(std::vector<std::vector<pagmo::population::size_type> > &,
const std::vector<std::vector<double> > &);
72 static double distance(
const std::vector<double> &,
const std::vector<double> &);
std::vector< population::size_type > order(const std::vector< T > &values)
Sort according the the values in the values vector but return the permutation.