36#include <sys/resource.h>
45#define MAXIMISING true
48#define BEATS(x,y) (x > y)
50#define BEATS(x,y) (x < y)
53#define WORSE(x,y) (BEATS(y,x) ? (x) : (y))
68 static int compare_tree_asc(
const void *p1,
const void *p2)
70 const double x1= *((
const double *)p1+1);
71 const double x2= *((
const double *)p2+1);
73 if (x1 != x2)
return (x1 > x2) ? -1 : 1;
78 int greater(
const void *v1,
const void *v2)
84 for (
int i =
n -
fr - 1; i >= 0; i--) {
86 for (
int i =
n - 1; i >= 0; i--) {
100 for (
int i =
n -
fr - 1; i >= 0; i--)
102 for (
int i =
n - 1; i >= 0; i--)
105 {
for (
int j = i - 1; j >= 0; j--)
110 {
for (
int j = i - 1; j >= 0; j--)
125 for (
int j = 0; j <
maxm; j++)
133 for (
int i = 0; i < z; i++)
134 for (
int j = 0; j <
n; j++)
138 for (
int i = 1; i < z; i++)
141 while (j <
fs[
fr].nPoints && keep)
150 default: keep =
false;
167 for (
int i = 1; i < ps.
nPoints; i++)
203 double hyperv = hypera * height;
205 for (
int i = ps.
nPoints - 2; i >= 0; i--) {
213 const double * prv_ip, * nxt_ip;
219 nxt_ip = (
double *)(tnode->
item);
222 nxt_ip = (tnode->
next!=NULL)
233 prv_ip = (
double *)(tnode->
item);
236 const double * cur_ip;
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]);
260 hypera -= (
ref.
objectives[1] - cur_ip[1])*(nxt_ip[0] - cur_ip[0]);
268 hypera += (prv_ip[1] -
275 hyperv += hypera * height;
286 for (
int i = 0; i <
n; i++)
314 if (
n == 2)
return hv2(ps);
322 for (
int i = 0; i < ps.
nPoints; i++) volume +=
exclhv(ps, i);
325 for (
int i = ps.
nPoints - 1; i >= 0; i--)
336 double FromFile(std::string file,
const std::vector<double>& referencePoint)
342 for (
int i = 0; i < f->
nFronts; i++)
360 for (
int i = 0; i < maxd; i++)
362 for (
int j = 0; j < maxp; j++)
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);
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);
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 * 1
e-6 - tv1.tv_sec - tv1.tv_usec * 1
e-6);
PETE_TUTree< FnFabs, typename T::PETE_Expr_t > fabs(const PETE_Expr< T > &l)
FILECONTENTS * readFile(const char filename[])
avl_node_t * avl_insert_after(avl_tree_t *avltree, avl_node_t *node, avl_node_t *newnode)
int avl_search_closest(const avl_tree_t *avltree, const void *item, avl_node_t **avlnode)
void avl_unlink_node(avl_tree_t *avltree, avl_node_t *avlnode)
avl_node_t * avl_init_node(avl_node_t *newnode, void *item)
avl_node_t * avl_insert_top(avl_tree_t *avltree, avl_node_t *newnode)
avl_tree_t * avl_alloc_tree(avl_compare_t cmp, avl_freeitem_t freeitem)
void avl_clear_tree(avl_tree_t *avltree)
void(* avl_freeitem_t)(void *)
int(* avl_compare_t)(const void *, const void *)
constexpr double e
The value of.
int dominates2way(POINT p, POINT q)
int greater(const void *v1, const void *v2)
double FromFile(std::string file, const std::vector< double > &referencePoint)
void makeDominatedBit(FRONT ps, int p)
double exclhv(FRONT ps, int p)
struct avl_node_t * tnode