-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_rw_top_trumps.c
64 lines (51 loc) · 1.53 KB
/
test_rw_top_trumps.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include "rw_top_trumps.h"
void perform_one_test(char *suite_name, size_t number_of_objectives, size_t function,
size_t instance, size_t dimension, const double *x) {
size_t i;
double *y;
y = (double *) malloc(dimension * sizeof(double));
evaluate_rw_top_trumps(suite_name, number_of_objectives, function, instance, dimension, x, y);
printf("function = %lu\ny = ", function);
for (i = 0; i < number_of_objectives; i++)
printf("%.4f\n", y[i]);
printf("\n");
fflush(stdout);
free(y);
}
int main(void) {
size_t function;
size_t instance = 3;
size_t dimension = 88;
size_t number_of_objectives = 1;
size_t i, m = 4;
double *x;
double *lb;
double *ub;
x = (double *) malloc(dimension * sizeof(double));
lb = (double *) malloc(m * sizeof(double));
ub = (double *) malloc(m * sizeof(double));
rw_top_trumps_bounds(instance, m, lb, ub);
/* Set x to be the middle of the domain */
for (i = 0; i < dimension; i++) {
if (i < 3)
printf("%lu lb = %f ub = %f\n", i, ub[i], lb[i]);
x[i] = (ub[i % m] + lb[i % m]) / 2;
}
free(lb);
free(ub);
printf("instance = %lu, objectives = %lu\n",
(unsigned long) instance,
(unsigned long) number_of_objectives);
printf("x = ");
for (i = 0; i < dimension; i++)
printf("%.0f ", x[i]);
printf("\n");
for (function = 1; function <= 5; function++) {
perform_one_test("rw-top-trumps", number_of_objectives, function, instance, dimension, x);
}
free(x);
printf("Done!\n");
fflush(stdout);
return 0;
}