Quantcast

Repast System Dynamics - order of stocks and rates calculation in generated code

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Repast System Dynamics - order of stocks and rates calculation in generated code

Michal Kecera
Hi,

I am encountering an issue after generating and running a code for my system dynamics model. The order of stocks and rates calculations in the generated code causes the rate to be updated to next period value before it's current value is added or subtracted from the stock it influences. This is happening only for some rates and stocks while others are in the correct order. I have included below a part of the code (stripped out the rest) which shows a different order of calculation for two similarly built stocks and flows. You'll notice that the rate is updated after the stock in the case of second stock while for the first it's updated before the stock. Also, for some reason, the part of code which calculates stock value is generated twice.

Not sure if I am doing something wrong when building up the diagram. Will be grateful for any suggestions. Is this something you encountered before or can someone shed some light on what drives the order in which the statements are generated for stocks and flows?

Thanks in advance for any advice.

Kind regards,

Michal.

{

/*

       Equation: Primary CL Pr= INTEG(Onboarding CL Pr,0)

 

       Units:people

 

       Comment: None Provided

 

*/

double _t0 = 0.0;

_t0 = sdFunctions.INTEG("Primary CL Pr",memory.Primary_CL_Pr,time,timeStep,(time == 0.0 ? 0.0 : (memory.Onboarding_CL_Pr) ),(0));

memory.Primary_CL_Pr = _t0;

/* log6 */logit("memory.Primary_CL_Pr",time,_t0,memory.get_SAVEPER());

}

 

{

/*

       Equation: Onboarding CL Pr=New CL Pr

 

       Units:people

 

       Comment: None Provided

 

*/

double _t0 = 0.0;

_t0 = memory.New_CL_Pr;

memory.Onboarding_CL_Pr = _t0;

/* log6 */logit("memory.Onboarding_CL_Pr",time,_t0,memory.get_SAVEPER());

}

 

{

/*

       Equation: Primary CL Pr= INTEG(Onboarding CL Pr,0)

 

       Units:people

 

       Comment: None Provided

 

*/

double _t0 = 0.0;

_t0 = sdFunctions.INTEG("Primary CL Pr",memory.Primary_CL_Pr,time,timeStep,(time == 0.0 ? 0.0 : (memory.Onboarding_CL_Pr) ),(0));

memory.Primary_CL_Pr = _t0;

/* log6 */logit("memory.Primary_CL_Pr",time,_t0,memory.get_SAVEPER());

}

 

{

/*

       Equation: Primary FU Pr= INTEG(Onboarding FU Pr,0)

 

       Units:people

 

       Comment: None Provided

 

*/

double _t0 = 0.0;

_t0 = sdFunctions.INTEG("Primary FU Pr",memory.Primary_FU_Pr,time,timeStep,(time == 0.0 ? 0.0 : (memory.Onboarding_FU_Pr) ),(0));

memory.Primary_FU_Pr = _t0;

/* log6 */logit("memory.Primary_FU_Pr",time,_t0,memory.get_SAVEPER());

}

 

{

/*

       Equation: Primary FU Pr= INTEG(Onboarding FU Pr,0)

 

       Units:people

 

       Comment: None Provided

 

*/

double _t0 = 0.0;

_t0 = sdFunctions.INTEG("Primary FU Pr",memory.Primary_FU_Pr,time,timeStep,(time == 0.0 ? 0.0 : (memory.Onboarding_FU_Pr) ),(0));

memory.Primary_FU_Pr = _t0;

/* log6 */logit("memory.Primary_FU_Pr",time,_t0,memory.get_SAVEPER());

}

{

/*

       Equation: Onboarding FU Pr=New FU Pr

 

       Units:people

 

       Comment: None Provided

 

*/

double _t0 = 0.0;

_t0 = memory.New_FU_Pr;

memory.Onboarding_FU_Pr = _t0;

/* log6 */logit("memory.Onboarding_FU_Pr",time,_t0,memory.get_SAVEPER());

}

 

 

 

 

 

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...