У меня есть эти коды в основной функции моей программы odeint:
int main(int argc, char **argv)
{
modelInit();
double v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16;
v1=1-pow(WB/param[WM],0.25);
v2=0;
v3=pow(WB/param[WM],0.25);
v4=0;
v5=0;
v6=0;
v7 =WB; //kg nonlabile weight
v8 =XB; //kg labile weight
v9 =WB;
v10 =XB;
v11=0; //kg (gravid uterus weight)
v12=delta*WB;// kg (digestive tract content weight)
v13=0; //MJ
v14=0;//MJ
v15=0;//Kg
v16=0;double conception;
double calving;
double dry_off=60;
afm f=read_afm();state_type x= {v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16};// initial conditions
typedef runge_kutta_dopri5< state_type > rk_dopri5; // error stepper
typedef controlled_runge_kutta< rk_dopri5 > ctrl_rk_dopri5; // controlled stepperconception = param[nubile_duration];
integrate_const( ctrl_rk_dopri5(), ode_system, x, 0.0, conception-1, 1.0, ode_write);
//from birth to first conception//x[1]=0.001;
x[3]=ev_epsilon;
calving = conception+param[pi];
integrate_const( ctrl_rk_dopri5(), ode_system, x, conception, calving-1, 1.0, ode_write);
//from conception to just before calving//
param[eD]=energy_density();
parity=1;
x[3]=0;
x[4]=val;
not_milk=0;
x[5]=2.49127154617638E-12;
conception = calving+f.pc1;
is_milking_b = true;
//dim=0;
integrate_const( ctrl_rk_dopri5(), ode_system, x, calving, conception-1, 1.0, ode_write);
//from calving to second conception//
cout<<"pc1="<<f.pc1<<endl;
x[3]=ev_epsilon;
dry_off=conception+param[pi]-dry_off;
integrate_const( ctrl_rk_dopri5(), ode_system, x, conception, dry_off-1, 1.0, ode_write);
//from second conception to just before dry_off//not_milk=1; //not_milking is true
is_milking_b = false;
calving=conception+param[pi];
integrate_const( ctrl_rk_dopri5(), ode_system, x, dry_off, calving-1, 1.0, ode_write); //you are here
//from dry_off to just before second calving//parity++;
dim=0;
x[3]=0;
x[4]=val;
not_milk=0;
is_milking_b = true;
conception=calving+f.pc2;
integrate_const( ctrl_rk_dopri5(), ode_system, x, calving, conception-1, 1.0, ode_write);
//from second calving to third conception
x[3]=ev_epsilon;
dry_off=conception+param[pi]-60;
integrate_const( ctrl_rk_dopri5(), ode_system, x, conception, dry_off-1, 1.0, ode_write);is_milking_b = false;
not_milk=1; //not_milking is true
calving=conception+param[pi];
integrate_const( ctrl_rk_dopri5(), ode_system, x, dry_off, calving-1, 1.0, ode_write); //you are here
//from dry_off to just before second calving//parity++;
is_milking_b = true;
dim=0;
x[3]=0;
x[4]=val;
not_milk=0;
conception=calving+f.pc3;
integrate_const( ctrl_rk_dopri5(), ode_system, x, calving, conception-1, 1.0, ode_write);
//from second calving to third conceptionx[3]=ev_epsilon;
dry_off=conception+param[pi]-60;
integrate_const( ctrl_rk_dopri5(), ode_system, x, conception, dry_off-1, 1.0, ode_write);
is_milking_b = false;
not_milk=1; //not_milking is true
calving=conception+param[pi];
integrate_const( ctrl_rk_dopri5(), ode_system, x, dry_off, calving-1, 1.0, ode_write); //you are here
//from dry_off to just before second calving//
Как видите, я пытаюсь сбросить начальное условие x, отделяя шаг времени интеграции вручную. Тем не менее, я думаю, что это так тривиально. Я пытался придумать лучший способ сделать это, но не смог добиться успеха. Не могли бы вы дать мне несколько подсказок.
Большое вам спасибо.
Фыонг
Задача ещё не решена.
Других решений пока нет …