9 # include "neighbourhood.h"
12 namespace pagmo{
namespace util {
namespace neighbourhood {
20 void euclidian::compute_neighbours(std::vector<std::vector<pagmo::population::size_type> > &retval,
const std::vector<std::vector<double> > &weights) {
21 for(
unsigned int i = 0; i < weights.size(); ++i) {
22 std::vector<double> distances;
23 for(
unsigned int j = 0; j < weights.size(); ++j) {
24 distances.push_back(distance(weights[i],weights[j]));
26 retval.push_back(
order(distances));
36 double euclidian::distance(
const std::vector<double> &a,
const std::vector<double> &b) {
38 for(std::vector<double>::size_type i = 0; i < a.size(); ++i) {
39 rtr += pow(a[i]-b[i], 2);
std::vector< population::size_type > order(const std::vector< T > &values)
Sort according the the values in the values vector but return the permutation.