36#include <sys/resource.h>
43#define MAXIMISING true
46#define BEATS(x,y) (x > y)
48#define BEATS(x,y) (x < y)
51#define WORSE(x,y) (BEATS(y,x) ? (x) : (y))
66 static int compare_tree_asc(
const void *p1,
const void *p2)
68 const double x1= *((
const double *)p1+1);
69 const double x2= *((
const double *)p2+1);
71 if (x1 != x2)
return (x1 > x2) ? -1 : 1;
76 int greater(
const void *v1,
const void *v2)
82 for (
int i =
n -
fr - 1; i >= 0; i--) {
84 for (
int i =
n - 1; i >= 0; i--) {
98 for (
int i =
n -
fr - 1; i >= 0; i--)
100 for (
int i =
n - 1; i >= 0; i--)
103 {
for (
int j = i - 1; j >= 0; j--)
108 {
for (
int j = i - 1; j >= 0; j--)
123 for (
int j = 0; j <
maxm; j++)
131 for (
int i = 0; i < z; i++)
132 for (
int j = 0; j <
n; j++)
136 for (
int i = 1; i < z; i++)
139 while (j <
fs[
fr].nPoints && keep)
148 default: keep =
false;
165 for (
int i = 1; i < ps.
nPoints; i++)
201 double hyperv = hypera * height;
203 for (
int i = ps.
nPoints - 2; i >= 0; i--) {
211 const double * prv_ip, * nxt_ip;
217 nxt_ip = (
double *)(tnode->
item);
220 nxt_ip = (tnode->
next!=NULL)
231 prv_ip = (
double *)(tnode->
item);
234 const double * cur_ip;
238 cur_ip = (
double *)(tnode->
item);
241 while (tnode->
prev) {
242 prv_ip = (
double *)(tnode->
prev->
item);
244 hypera -= (prv_ip[1] - cur_ip[1])*(nxt_ip[0] - cur_ip[0]);
258 hypera -= (
ref.
objectives[1] - cur_ip[1])*(nxt_ip[0] - cur_ip[0]);
266 hypera += (prv_ip[1] -
273 hyperv += hypera * height;
284 for (
int i = 0; i <
n; i++)
312 if (
n == 2)
return hv2(ps);
320 for (
int i = 0; i < ps.
nPoints; i++) volume +=
exclhv(ps, i);
323 for (
int i = ps.
nPoints - 1; i >= 0; i--)
334 double FromFile(std::string file,
const std::vector<double>& referencePoint)
340 for (
int i = 0; i < f->
nFronts; i++)
358 for (
int i = 0; i < maxd; i++)
360 for (
int j = 0; j < maxp; j++)
379 if (referencePoint.empty()) {
380 printf(
"No reference point provided: using the origin\n");
381 }
else if ((
int)referencePoint.size() !=
maxn) {
382 printf(
"Your reference point should have %d values: using the origin\n",
maxn);
387 for (
int i = 0; i < f->
nFronts; i++)
389 struct timeval tv1, tv2;
390 struct rusage ru_before, ru_after;
391 getrusage (RUSAGE_SELF, &ru_before);
405 getrusage (RUSAGE_SELF, &ru_after);
406 tv1 = ru_before.ru_utime;
407 tv2 = ru_after.ru_utime;
408 printf(
"Time: %f (s)\n", tv2.tv_sec + tv2.tv_usec * 1e-6 - tv1.tv_sec - tv1.tv_usec * 1e-6);
PETE_TUTree< FnFabs, typename T::PETE_Expr_t > fabs(const PETE_Expr< T > &l)
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)
FILECONTENTS * readFile(const char filename[])
void(* avl_freeitem_t)(void *)
int(* avl_compare_t)(const void *, const void *)
int dominates2way(POINT p, POINT q)
int greater(const void *v1, const void *v2)
void makeDominatedBit(FRONT ps, int p)
double exclhv(FRONT ps, int p)
Sampling method that reads design variable values from a text file.
struct avl_node_t * tnode