100 for (
int i =
n -
fr - 1; i >= 0; i--)
102 for (
int i =
n - 1; i >= 0; i--)
104 if BEATS(p.objectives[i],q.objectives[i])
105 {
for (
int j = i - 1; j >= 0; j--)
106 if BEATS(q.objectives[j],p.objectives[j])
return 0;
109 if BEATS(q.objectives[i],p.objectives[i])
110 {
for (
int j = i - 1; j >= 0; j--)
111 if BEATS(p.objectives[j],q.objectives[j])
return 0;
165 double volume =
fabs((ps.points[0].objectives[0] -
ref.objectives[0]) *
166 (ps.points[0].objectives[1] -
ref.objectives[1]));
167 for (
int i = 1; i < ps.nPoints; i++)
168 volume +=
fabs((ps.points[i].objectives[0] -
ref.objectives[0]) *
169 (ps.points[i].objectives[1] - ps.points[i - 1].objectives[1]));
191 avl_init_node(ps.points[ps.nPoints-1].tnode,ps.points[ps.nPoints-1].objectives);
194 double hypera = (
ref.objectives[0] - ps.points[ps.nPoints-1].objectives[0]) *
195 (
ref.objectives[1] - ps.points[ps.nPoints-1].objectives[1]);
199 height =
ref.objectives[2] - ps.points[ps.nPoints-1].objectives[2];
201 height = ps.points[ps.nPoints-2].objectives[2] - ps.points[ps.nPoints-1].objectives[2];
203 double hyperv = hypera * height;
205 for (
int i = ps.nPoints - 2; i >= 0; i--) {
208 height =
ref.objectives[2] - ps.points[i].objectives[2];
210 height = ps.points[i-1].objectives[2] - ps.points[i].objectives[2];
213 const double * prv_ip, * nxt_ip;
219 nxt_ip = (
double *)(tnode->
item);
222 nxt_ip = (tnode->
next!=NULL)
227 if (nxt_ip[0] > ps.points[i].objectives[0]) {
233 prv_ip = (
double *)(tnode->
item);
235 if (prv_ip[0] > ps.points[i].objectives[0]) {
236 const double * cur_ip;
238 tnode = ps.points[i].tnode->
prev;
240 cur_ip = (
double *)(tnode->
item);
243 while (tnode->
prev) {
244 prv_ip = (
double *)(tnode->
prev->
item);
246 hypera -= (prv_ip[1] - cur_ip[1])*(nxt_ip[0] - cur_ip[0]);
247 if (prv_ip[0] < ps.points[i].objectives[0])
260 hypera -= (
ref.objectives[1] - cur_ip[1])*(nxt_ip[0] - cur_ip[0]);
261 prv_ip =
ref.objectives;
265 prv_ip =
ref.objectives;
268 hypera += (prv_ip[1] -
269 ps.points[i].objectives[1])*(nxt_ip[0] -
270 ps.points[i].objectives[0]);
275 hyperv += hypera * height;
336 double FromFile(std::string file,
const std::vector<double>& referencePoint)
342 for (
int i = 0; i < f->nFronts; i++)
344 if (f->fronts[i].nPoints >
maxm)
maxm = f->fronts[i].nPoints;
345 if (f->fronts[i].n >
maxn)
maxn = f->fronts[i].n;
360 for (
int i = 0; i < maxd; i++)
362 for (
int j = 0; j < maxp; j++)
379 for (
int i = 0; i <
maxn; i++)
ref.objectives[i] = 0;
381 if (referencePoint.empty()) {
382 printf(
"No reference point provided: using the origin\n");
383 }
else if ((
int)referencePoint.size() !=
maxn) {
384 printf(
"Your reference point should have %d values: using the origin\n",
maxn);
386 for (
int i = 0; i <
maxn; i++)
ref.objectives[i] = referencePoint[i];
389 for (
int i = 0; i < f->nFronts; i++)
391 struct timeval tv1, tv2;
392 struct rusage ru_before, ru_after;
393 getrusage (RUSAGE_SELF, &ru_before);
398 {qsort(f->fronts[i].points, f->fronts[i].nPoints,
sizeof(
POINT),
greater);
400 return hv2(f->fronts[i]);
405 return hv(f->fronts[i]);
407 getrusage (RUSAGE_SELF, &ru_after);
408 tv1 = ru_before.ru_utime;
409 tv2 = ru_after.ru_utime;
410 printf(
"Time: %f (s)\n", tv2.tv_sec + tv2.tv_usec * 1e-6 - tv1.tv_sec - tv1.tv_usec * 1e-6);