Skip to content

Commit e55dcfb

Browse files
committed
trying to make a test to validate the obj_function output
1 parent cce018f commit e55dcfb

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ foreach(test_name
88
test_data_reader
99
test_ess_solver
1010
test_parse_cuqdyn_conf
11+
test_ess_obj_function
1112
test_cuqdyn_algo
1213
)
1314
add_executable(${test_name} ${test_name}.c)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<cuqdyn-config>
4+
<tolerances>
5+
<rtol>1e-8</rtol>
6+
<atol>1e-12, 1e-12, 1e-12, 1e-12 1e-12</atol>
7+
</tolerances>
8+
<ode_expr y_count="5" p_count="5">
9+
alpha-pinene
10+
</ode_expr>
11+
</cuqdyn-config>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<xml>
2+
<run>
3+
<typebench>customized</typebench>
4+
<id>0</id>
5+
<log_scale>5</log_scale>
6+
<output>1</output>
7+
<verbose>1</verbose>
8+
<local_search>1</local_search>
9+
<stopping_criteria>
10+
<maxevaluation>3e3</maxevaluation>
11+
<maxtime>1e10</maxtime>
12+
<vtr>0</vtr>
13+
</stopping_criteria>
14+
</run>
15+
<method name="ScatterSearch">
16+
<user_options>
17+
<weight>default</weight>
18+
<tolc>default</tolc>
19+
<prob_bound>default</prob_bound>
20+
<nstuck_solution>default</nstuck_solution>
21+
</user_options>
22+
<global_options>
23+
<dim_ref>default</dim_ref>
24+
<ndiverse>default</ndiverse>
25+
<combination>default</combination>
26+
<n_stuck>default</n_stuck>
27+
</global_options>
28+
<local_options>
29+
<solver>nl2sol.dn2fb</solver>
30+
<tol>0</tol>
31+
<evalmax>3e3</evalmax>
32+
<iterprint>0</iterprint>
33+
<n1>1</n1>
34+
<n2>10</n2>
35+
<balance>0.25</balance>
36+
<bestx>default</bestx>
37+
</local_options>
38+
</method>
39+
<parallelization name="cooperative">
40+
<!-- saCeSS options -->
41+
<reception_threshold>1</reception_threshold>
42+
<evals_threshold>1000</evals_threshold>
43+
<mult_num_sendSol>10</mult_num_sendSol>
44+
<minimum_num_sendSol>20</minimum_num_sendSol>
45+
<!-- CeSS option: migration time -->
46+
<migration_max_time>10</migration_max_time>
47+
</parallelization>
48+
49+
<problem>
50+
<dim> 5 </dim>
51+
<neq> 0 </neq>
52+
<ineq> 0 </ineq>
53+
<int_var> 0 </int_var>
54+
<bin_var> 0 </bin_var>
55+
<lb>
56+
0, 0, 0, 0, 0
57+
</lb>
58+
<ub>
59+
1, 1, 1, 1, 1
60+
</ub>
61+
<point>
62+
1, 1, 1, 1, 1
63+
</point>
64+
</problem>
65+
66+
</xml>

tests/test_ess_obj_function.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "data_reader.h"
2+
#include "functions.h"
3+
#include "matlab.h"
4+
#include "method_module/structure_paralleltestbed.h"
5+
6+
#define CUQDYN_CONF "data/obj_function_cuqdyn_config.xml"
7+
#define SACESS_CONF "data/obj_function_ess_config_nl2sol.dn2fb.xml"
8+
#define DATA "data/alpha_pinene_paper_data.txt"
9+
10+
int main()
11+
{
12+
init_cuqdyn_conf_from_file(CUQDYN_CONF);
13+
14+
N_Vector texp = NULL;
15+
SUNMatrix yexp = NULL;
16+
17+
read_data_file(DATA, &texp, &yexp);
18+
N_Vector initial_values = copy_matrix_row(yexp, 0, 0, SM_COLUMNS_D(yexp));
19+
20+
experiment_total *exp_total = malloc(sizeof(experiment_total));
21+
create_expetiment_struct(SACESS_CONF, &exp_total[0], 1, 0, "output", 1, texp, yexp, initial_values);
22+
23+
double x[5] = {1.0, 1.0, 1.0, 1.0, 1.0};
24+
25+
output_function *out = ode_model_obj_func(x, exp_total);
26+
27+
printf("VAlue %lf", out->value);
28+
29+
destroyexp(exp_total);
30+
return 0;
31+
}

0 commit comments

Comments
 (0)