Hello,
I need to calculate a value at a given point in time and pass that value as a constant for the rest of the simulation run. For example, in the attached simple model, FINAL TIME = 10. 'Additional item promotion budget' is a Gaming variable and If I enter $100 at TIME=5, the following variable, 'Additional item daily promotion budget', correctly calculates that as $20/Day ($100/Time remaining). I need 'Additional item daily promotion budget' (or a new variable) to remain at $20/Day from the time of that calculation to the end of the run (the Gaming variable is returned to zero at the subsequent time step) but I can't see how to pass the calculation at a single point in time to a constant value and i'd be grateful for some guidance!
Phill
Creating a constant value
Creating a constant value
- Attachments
-
- budget division.mdl
- (1.97 KiB) Downloaded 162 times
-
- Super Administrator
- Posts: 4589
- Joined: Wed Mar 05, 2003 3:10 am
Re: Creating a constant value
I'm not sure I get what is going on here. If I start a game, continue until t=5 and change "additional item promotion budget"=20, and then hit continue until time=20, the value in "additional item promotion budget" remains at 20.
Time (Month) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
"additional item daily promotion budget[menu]" Runs: Current
additional item daily promotion budget[MENU ITEM A] 0 0 0 0 0 0.210526 0.212766 0.215054 0.217391 0.21978 0.222222 0.224719 0.227273 0.229885 0.232558 0.235294 0.238095 0.240964 0.243902 0.246914 0.25
"additional item promotion budget[menu]" Runs: Current
additional item promotion budget[MENU ITEM A] 0 0 0 0 0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
Time (Month) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
"additional item daily promotion budget[menu]" Runs: Current
additional item daily promotion budget[MENU ITEM A] 0 0 0 0 0 0.210526 0.212766 0.215054 0.217391 0.21978 0.222222 0.224719 0.227273 0.229885 0.232558 0.235294 0.238095 0.240964 0.243902 0.246914 0.25
"additional item promotion budget[menu]" Runs: Current
additional item promotion budget[MENU ITEM A] 0 0 0 0 0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Creating a constant value
SAMPLE IF TRUE can be used to freeze the value of a calculation at some point.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Creating a constant value
I didn't explain that very well. The model has a javascript interface that will return 'additional item promotion budget' to zero after 1 time step, so it only carries the value of '100' for one time step.In this sketch view, you can see that the value of '20' was correctly calculated at TIME=5, but I want the variable 'additional item daily promotional budget' to then carry that value for all the remaining time steps.
-
- Super Administrator
- Posts: 4589
- Joined: Wed Mar 05, 2003 3:10 am
Re: Creating a constant value
As Tom says, you'll need a SAMPLE IF TRUE as well to hold the value.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Creating a constant value
Ah, thank you...I wasn't sure what to search for!!
Re: Creating a constant value
I'm sorry to be persistent, but this has piqued my interest now! I've added a 'Sample if true' variable and it works, but the value is augmented in the time steps subsequent to the calculation (the updated model is attached). I assume that this explanation in the help files is relevant,
If you are using an integration technique other then Euler, the value of the output of the SAMPLE IF TRUE function will change within the integration step, though the reported value will always be computed on an even time step. Thus if TIME STEP is 1 and using RK4 Auto integration project is started becomes non-zero at time 3.25, starting time will be reported as 4.0. If any other variables use starting time they may receive a value of between 3.25 and 4.0 within the integration step.
So, if I add $100 to the GAME variable at Time=6. I get '25' as the correct value for 'Constant additional promotion budget' at time ste 6, but '33.333' for all subsequent time steps.
If you are using an integration technique other then Euler, the value of the output of the SAMPLE IF TRUE function will change within the integration step, though the reported value will always be computed on an even time step. Thus if TIME STEP is 1 and using RK4 Auto integration project is started becomes non-zero at time 3.25, starting time will be reported as 4.0. If any other variables use starting time they may receive a value of between 3.25 and 4.0 within the integration step.
So, if I add $100 to the GAME variable at Time=6. I get '25' as the correct value for 'Constant additional promotion budget' at time ste 6, but '33.333' for all subsequent time steps.
- Attachments
-
- budget division.mdl
- (2.36 KiB) Downloaded 165 times
Re: Creating a constant value
I submitted that last comment before I had finished and I meant to add that this small model does use Euler integration.
Phill
Phill
Re: Creating a constant value
This may be a quirk of the computation of SAMPLE IF TRUE combined with a gaming variable.
You can use a level instead. Add:
Max budget to date[Menu]= INTEG (
MAX(0,Additional item daily promotion budget[Menu]-Max budget to date[Menu])/TIME STEP,
0)
Units: $/Day
Then get rid of the SAMPLE:
Constant additional promotion budget[Menu]=
MAX(Max budget to date[Menu],Additional item daily promotion budget[Menu])
Units: $/Day
You can use a level instead. Add:
Max budget to date[Menu]= INTEG (
MAX(0,Additional item daily promotion budget[Menu]-Max budget to date[Menu])/TIME STEP,
0)
Units: $/Day
Then get rid of the SAMPLE:
Constant additional promotion budget[Menu]=
MAX(Max budget to date[Menu],Additional item daily promotion budget[Menu])
Units: $/Day
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Creating a constant value
That works perfectly, thank you.
Phill
Phill