我在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 stepper
conception = 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 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//
如您所见,我试图通过手动分离积分时间步骤来重置x的初始条件。但是,我认为这样做似乎是微不足道的。我一直在努力想出一个更好的方法,但却无法成功。你能给我一些帮助/提示吗? 非常感谢你。 PHUONG