31 #ifndef SHARK_ALGORITHMS_DIRECTSEARCH_HYPERVOLUMECALCULATOR_2D_H 32 #define SHARK_ALGORITHMS_DIRECTSEARCH_HYPERVOLUMECALCULATOR_2D_H 50 template<
typename Set,
typename VectorType >
58 std::vector<shark::KeyValuePair<double,double> >
set(points.size());
59 for(std::size_t i = 0; i != points.size(); ++i){
60 set[i].key = points[i][0];
61 set[i].value = points[i][1];
63 std::sort(
set.begin(),
set.end());
66 double volume = ( refPoint[0] -
set[0].key ) * ( refPoint[1] -
set[0].value);
68 std::size_t lastValidIndex = 0;
69 for( std::size_t i = 1; i <
set.size(); ++i ) {
70 double diffDim1 =
set[lastValidIndex].value -
set[i].value;
74 volume += ( refPoint[0] -
set[i].key ) * diffDim1;