Skip to content

Commit c227846

Browse files
committed
tried to solve alpha-pinene but the ode solver its taking a hard time with it
1 parent 2100db6 commit c227846

File tree

7 files changed

+243
-2
lines changed

7 files changed

+243
-2
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<cuqdyn-config>
4+
<tolerances>
5+
<rtol>10</rtol>
6+
<atol>10, 10, 10, 10, 10</atol>
7+
</tolerances>
8+
<ode_expr y_count="5" p_count="5">
9+
-(p1 + p2) * y1
10+
p1 * y1
11+
p2 * y1 - (p3 + p4) * y3 + p5 * y5
12+
p3 * y3
13+
p4 * y3 - p5 * y5
14+
</ode_expr>
15+
</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>0</output>
7+
<verbose>1</verbose>
8+
<local_search>1</local_search>
9+
<stopping_criteria>
10+
<maxevaluation>375</maxevaluation>
11+
<maxtime>1e10</maxtime>
12+
<vtr>0</vtr>
13+
</stopping_criteria>
14+
</run>
15+
<method name="CeSS">
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>9e3</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>1</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+
<initial_point>
62+
1, 1, 1, 1, 1
63+
</initial_point>
64+
</problem>
65+
66+
</xml>
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>4</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+
<initial_point>
62+
1, 1, 1, 1, 1
63+
</initial_point>
64+
</problem>
65+
66+
</xml>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
9 6
2+
0 1.409e-01 3.034e-02 1.409e-01 3.034e-02 3.252e-02
3+
1230 3.441e+00 6.992e-02 3.441e+00 6.992e-02 4.046e-01
4+
3060 5.622e+00 1.027e-01 5.622e+00 1.027e-01 3.011e+00
5+
4920 5.316e+00 5.430e-01 5.316e+00 5.430e-01 4.136e+00
6+
7800 6.977e+00 5.887e-01 6.977e+00 5.887e-01 9.308e+00
7+
10680 7.298e+00 9.356e-01 7.298e+00 9.356e-01 1.277e+01
8+
15030 5.795e+00 1.468e+00 5.795e+00 1.468e+00 1.797e+01
9+
22620 5.169e+00 1.443e+00 5.169e+00 1.443e+00 2.250e+01
10+
36420 4.175e+00 4.301e+00 4.175e+00 4.301e+00 2.232e+01

tests/data/alpha_pinene_cuqdyn_config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<cuqdyn-config>
44
<tolerances>
5-
<rtol>1e-12</rtol>
6-
<atol>1e-12, 1e-12, 1e-12, 1e-12, 1e-12</atol>
5+
<rtol>1e-8</rtol>
6+
<atol>1e-8, 1e-8, 1e-8, 1e-8, 1e-8</atol>
77
</tolerances>
88
<ode_expr y_count="5" p_count="5">
99
-(p1 + p2) * y1
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
9 6
2+
0 1.409e-01 3.034e-02 1.409e-01 3.034e-02 3.252e-02
3+
1230 3.441e+00 6.992e-02 3.441e+00 6.992e-02 4.046e-01
4+
3060 5.622e+00 1.027e-01 5.622e+00 1.027e-01 3.011e+00
5+
4920 5.316e+00 5.430e-01 5.316e+00 5.430e-01 4.136e+00
6+
7800 6.977e+00 5.887e-01 6.977e+00 5.887e-01 9.308e+00
7+
10680 7.298e+00 9.356e-01 7.298e+00 9.356e-01 1.277e+01
8+
15030 5.795e+00 1.468e+00 5.795e+00 1.468e+00 1.797e+01
9+
22620 5.169e+00 1.443e+00 5.169e+00 1.443e+00 2.250e+01
10+
36420 4.175e+00 4.301e+00 4.175e+00 4.301e+00 2.232e+01
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+

tests/test_ess_solver.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ int main(int argc, char **argv)
3232
lotka_volterra_ess(LOTKA_VOLTERRA_CONF_FILE_MISQP);
3333
printf("\tTest 4 passed MISQP\n");
3434

35+
alpha_pinene_ess(LOTKA_VOLTERRA_CONF_FILE_NL2SOL_DN2GB);
36+
printf("\tTest 5 passed NL2SOL_DN2GB\n");
37+
3538
return 0;
3639
}
3740

@@ -82,3 +85,61 @@ void lotka_volterra_ess(char *conf_file)
8285

8386
destroy_cuqdyn_conf();
8487
}
88+
89+
void alpha_pinene_ess(char *conf_file)
90+
{
91+
init_cuqdyn_conf_from_file("data/alpha_pinene_cuqdyn_config.xml");
92+
93+
realtype expected_values[5] = {5.93e-5, 2.96e-5, 2.05e-5, 2.75e-5, 4.00e-5};
94+
95+
N_Vector texp = N_VNew_Serial(9, get_sun_context());
96+
NV_Ith_S(texp, 0) = 0;
97+
NV_Ith_S(texp, 1) = 1230;
98+
NV_Ith_S(texp, 2) = 3060;
99+
NV_Ith_S(texp, 3) = 4920;
100+
NV_Ith_S(texp, 4) = 7800;
101+
NV_Ith_S(texp, 5) = 10680;
102+
NV_Ith_S(texp, 6) = 15030;
103+
NV_Ith_S(texp, 7) = 22620;
104+
NV_Ith_S(texp, 8) = 36420;
105+
106+
DlsMat yexp = SUNDenseMatrix(9, 5, get_sun_context());
107+
108+
realtype yexp_data[9][5] = {{1.409e-01, 3.034e-02, 1.409e-01, 3.034e-02, 3.252e-02},
109+
{3.441e+00, 6.992e-02, 3.441e+00, 6.992e-02, 4.046e-01},
110+
{5.622e+00, 1.027e-01, 5.622e+00, 1.027e-01, 3.011e+00},
111+
{5.316e+00, 5.430e-01, 5.316e+00, 5.430e-01, 4.136e+00},
112+
{6.977e+00, 5.887e-01, 6.977e+00, 5.887e-01, 9.308e+00},
113+
{7.298e+00, 9.356e-01, 7.298e+00, 9.356e-01, 1.277e+01},
114+
{5.795e+00, 1.468e+00, 5.795e+00, 1.468e+00, 1.797e+01},
115+
{5.169e+00, 1.443e+00, 5.169e+00, 1.443e+00, 2.250e+01},
116+
{4.175e+00, 4.301e+00, 4.175e+00, 4.301e+00, 2.232e+01}};
117+
118+
N_Vector initial_values = N_VNew_Serial(5, get_sun_context());
119+
NV_Ith_S(initial_values, 0) = 100;
120+
NV_Ith_S(initial_values, 1) = 0.0001;
121+
NV_Ith_S(initial_values, 2) = 0.0001;
122+
NV_Ith_S(initial_values, 3) = 0.0001;
123+
NV_Ith_S(initial_values, 4) = 0.0001;
124+
125+
for (int i = 0; i < 9; ++i)
126+
{
127+
for (int j = 0; j < 5; ++j)
128+
{
129+
SM_ELEMENT_D(yexp, i, j) = yexp_data[i][j];
130+
}
131+
}
132+
133+
N_Vector xbest = execute_ess_solver(conf_file, OUPUT_PATH, texp, yexp, initial_values, 0, 1);
134+
135+
for (int i = 0; i < 4; ++i)
136+
{
137+
realtype expected = expected_values[i];
138+
realtype result = NV_Ith_S(xbest, i);
139+
140+
realtype a = 6;
141+
// assert(fabs(result - expected) < 0.1);
142+
}
143+
144+
destroy_cuqdyn_conf();
145+
}

0 commit comments

Comments
 (0)