Potential bug in STEP and RAMP initialization
Posted: Tue Jul 19, 2022 10:52 am
Potential bug in STEP and RAMP initialization, and probably similar functions.
I have noticed that both RAMP and STEP are executed when TIME + TIME STEP/2 > start time and TIME +TIME STEP/2 > step time, respectively.
This could produce a bug when the start time (or step time) is not a multiple of the time step. For example, the function
with INITIAL TIME = 0; FINAL TIME = 3; TIME STEP = SAVEPER = 1
produces the output
which has a negative value! This is because it is computing when TIME < start time. This value could make some models fail as the ramp return a value outside the expected value rang [0, slope*(final time - start time)].The expected output should be
similar happens to step:
with the same control variables produces:
when the expected output would be:
I know that is not desirable to have the start time not being a multiple of time step but this could happen sometimes. A possible workaround would be to use the same constant used to ZIDZ and XIDZ to avoid numerical error in comparison, i.e., start the RAMP and STEP when TIME + 1E-6 > start time or TIME + 1E-6 > step time.
I am using Vensim DSS 9.2.4 x64 in Windows.
Find the model attached. Thank you
I have noticed that both RAMP and STEP are executed when TIME + TIME STEP/2 > start time and TIME +TIME STEP/2 > step time, respectively.
This could produce a bug when the start time (or step time) is not a multiple of the time step. For example, the function
Code: Select all
RAMP(1, 0.45, 10)
produces the output
Code: Select all
0 1 2 3
-0.45 0.55 1.55 2.55
Code: Select all
slope*(TIME- start time)
Code: Select all
0 1 2 3
0 0.55 1.55 2.55
Code: Select all
STEP(1, 0.45)
Code: Select all
0 1 2 3
1 1 1 1
Code: Select all
0 1 2 3
0 1 1 1
I am using Vensim DSS 9.2.4 x64 in Windows.
Find the model attached. Thank you