Using data from the previous time // Vensim PLE
Using data from the previous time // Vensim PLE
Hello,
To calculate the value of an auxiliary variable I need its value in t-1, i.e, its value in the previous period.
For example, the variable is speed.
I created the variables "speed (t)" and "speed (t-1)", where
Speed (t) = Speed (t-1) * EXP (0.034 * (Variable z - Variable y)) and
Speed (t-1) = IF THEN ELSE (Time = 0, 9758, GET DATA AT TIME(Speed (t), Time-1))
Thus, the initial speed is 9758, that is, the value at time = 0. In addition, the speed for time > = 1 will be calculated based on the speed of the previous time. However, the GET DATA AT TIME function is not available in the Vensim PLE.
Therefore, I need to find a way to assign an initial value to an auxiliary variable and calculate its value in the following periods using the value of that variable in the previous time (t-1).
Does anyone have any suggestions on how to do this in VENSIM PLE ??
Thanks in advance,
Wlisses.
To calculate the value of an auxiliary variable I need its value in t-1, i.e, its value in the previous period.
For example, the variable is speed.
I created the variables "speed (t)" and "speed (t-1)", where
Speed (t) = Speed (t-1) * EXP (0.034 * (Variable z - Variable y)) and
Speed (t-1) = IF THEN ELSE (Time = 0, 9758, GET DATA AT TIME(Speed (t), Time-1))
Thus, the initial speed is 9758, that is, the value at time = 0. In addition, the speed for time > = 1 will be calculated based on the speed of the previous time. However, the GET DATA AT TIME function is not available in the Vensim PLE.
Therefore, I need to find a way to assign an initial value to an auxiliary variable and calculate its value in the following periods using the value of that variable in the previous time (t-1).
Does anyone have any suggestions on how to do this in VENSIM PLE ??
Thanks in advance,
Wlisses.
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Using data from the previous time // Vensim PLE
GET DATA AT TIME is for getting data from external data files, not from the current simulation.
You can use DELAY FIXED to get the value of a variable at a previous time step. The delay time will be "time step".
You can use DELAY FIXED to get the value of a variable at a previous time step. The delay time will be "time step".
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: Using data from the previous time // Vensim PLE
/*
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: Using data from the previous time // Vensim PLE
Looking at this equation, I see several other problems. For one thing, the constant .034 is embedded with no obvious interpretation, as is 9758. Unless the variables are dimensionless, this won't pass a units check.
https://metasd.com/2019/11/seven-deadly ... structure/
I would suggest a more physical model, like:
Acceleration = f( variables, parameters )
Speed = INTEG( acceleration, initial speed )
Initial speed = 9758 ~ units?
https://metasd.com/2019/11/seven-deadly ... structure/
I would suggest a more physical model, like:
Acceleration = f( variables, parameters )
Speed = INTEG( acceleration, initial speed )
Initial speed = 9758 ~ units?
/*
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: Using data from the previous time // Vensim PLE
Thanks!!!!Administrator wrote: ↑Tue May 19, 2020 1:54 pm GET DATA AT TIME is for getting data from external data files, not from the current simulation.
You can use DELAY FIXED to get the value of a variable at a previous time step. The delay time will be "time step".
Re: Using data from the previous time // Vensim PLE
Thanks!!!!tomfid wrote: ↑Tue May 19, 2020 2:42 pm Looking at this equation, I see several other problems. For one thing, the constant .034 is embedded with no obvious interpretation, as is 9758. Unless the variables are dimensionless, this won't pass a units check.
https://metasd.com/2019/11/seven-deadly ... structure/
I would suggest a more physical model, like:
Acceleration = f( variables, parameters )
Speed = INTEG( acceleration, initial speed )
Initial speed = 9758 ~ units?
Re: Using data from the previous time // Vensim PLE
Hi Tomfid.tomfid wrote: ↑Tue May 19, 2020 2:42 pm Looking at this equation, I see several other problems. For one thing, the constant .034 is embedded with no obvious interpretation, as is 9758. Unless the variables are dimensionless, this won't pass a units check.
https://metasd.com/2019/11/seven-deadly ... structure/
I would suggest a more physical model, like:
Acceleration = f( variables, parameters )
Speed = INTEG( acceleration, initial speed )
Initial speed = 9758 ~ units?
I still have some problems. Can you help me?
The traffic congestion variable is dimensionless and it is calculated using other variables from the model.
I'm still working in the relationship between congestion and speed (speed formula). However I think I'm using the delay fixed function in a wrong way.The initial value for speed and number of accidents is 40 and 10000, respectively.
The adopted equations are:
Speed = IF THEN ELSE(PREVIOUS TRAFFIC CONGESTION/Traffic Congestion < 0.95, Previous Speed*1.02 , Previous Speed )
Previous Speed = DELAY FIXED(Speed, 1 , 40 )
DELAY FIXED( Traffic Congestion , 1 , 0 )
Previous number of accidents = DELAY FIXED(Number of Accidents, 1 , 10000 )
Number of accidents = Previous number of accidents*EXP(0.034*(Speed-Previous Speed))
IMAGE:https://ibb.co/tZ3wf1v
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Using data from the previous time // Vensim PLE
It would be easier to upload the model. Posting equations and an image means we need to spend precious time replicating it in Vensim.
Before uploading, remove the numbers from your equations and assign them to separate Vensim constants. For example, what is 0.95? Create a constant, give it the value 0.95 and correct units. We have no chance of understanding a model with embedded constants unless they are completely obvious (for example, 3.14).
Before uploading, remove the numbers from your equations and assign them to separate Vensim constants. For example, what is 0.95? Create a constant, give it the value 0.95 and correct units. We have no chance of understanding a model with embedded constants unless they are completely obvious (for example, 3.14).
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: Using data from the previous time // Vensim PLE
Hi, I made the changes.Administrator wrote: ↑Wed May 20, 2020 10:24 am It would be easier to upload the model. Posting equations and an image means we need to spend precious time replicating it in Vensim.
Before uploading, remove the numbers from your equations and assign them to separate Vensim constants. For example, what is 0.95? Create a constant, give it the value 0.95 and correct units. We have no chance of understanding a model with embedded constants unless they are completely obvious (for example, 3.14).
I am sending the model. I want to understand the use of DELAY FIXED to get the value of the variable in the previous period.
The variable "number of accidents" must be 10000 at time=0. The speed starts with 40 km/h.
The model:
https://www.dropbox.com/s/2pfqusvs7s21n ... l.mdl?dl=0
Re: Using data from the previous time // Vensim PLE
You've initialized "previous speed" to 0. Initialize it to "speed" or 40 and it should work.
However... it won't be a good dynamic model. I'm guessing that this is a replication of some kind of regression study, in which someone took the underlying physics of the situation, differentiated and discretized time. That might be necessary for using some stats package, but it would be better to have a more physical model.
For example:
congestion = ...
speed = INTEG(acceleration, init speed)
acceleration = f( congestion )
accidents = g( speed, congestion )
The current formulation with accidents = f( previous accidents, acceleration ) is really unphysical.
However... it won't be a good dynamic model. I'm guessing that this is a replication of some kind of regression study, in which someone took the underlying physics of the situation, differentiated and discretized time. That might be necessary for using some stats package, but it would be better to have a more physical model.
For example:
congestion = ...
speed = INTEG(acceleration, init speed)
acceleration = f( congestion )
accidents = g( speed, congestion )
The current formulation with accidents = f( previous accidents, acceleration ) is really unphysical.
/*
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: Using data from the previous time // Vensim PLE
Also, all parameters should be made into explicit variables with assigned units. This includes dimensionless parameters, because they should be exposed to sensitivity analysis, documented and consistent if used more than once. The only exception is things that are invariant or definitional, like 1 or pi.
/*
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
*/