I’ve entered a tabbed array in vensim. (No problem here. I imitated the sample and VENSIM seems happy enough.)
How do I have the model read a value out of it and assign it to a variable? Based on other instantaneous states in the model, I want x to be the value in row 3 column 5 of the array for this time step in order to make further calculations. Later, row 2 column 1. I have a variable for desired row, and a variable for desired column (eg. r=2 and c=1 for row 2 column 1)
Background/project:
I’m using vensim to model rivers and reservoir systems, and I’m using lookups for things like “reservoir release for ecosystem health” that changes based on a weather classification (wet, dry, or normal) and the time of year (monthly). It would be a 3 row, 12 column matrix.
It is currently programmed in as 3 lookups with 12 values each (f_wet, f_dry, and f_normal),
a function defining the weather patterns,
weather classification =
IF THEN ELSE (cumulative rainfall<3, 1, // dry
IF THEN ELSE (cumulative rainfall<7, 2, // normal
3)) // wet
and then another if statement choosing the correct lookup and pulling the value based on month.
release for ecosystem health =
IF THEN ELSE (weather classification = 1, f_dry(month), IF THEN ELSE (weather classification =2, f_normal(month), f_wet(month)))
This setup works and has been running, but I’m now looking at weather in a higher resolution (more categories for rainfall), and at different sets of releases for different reservoirs, and the number of variables is getting out of hand. (f_verywet_reservoir1, f_verywet_reservoir2, etc.)
I’m envisoning one definition of weather classification and one function to count the month, plus one tabbed array for each reservoir to assign a value to that reservoir’s release.
Potentially something like
variable =
LOOKUP FUNCTION OF SOME KIND (name of tabbed array, row, column)
which in my case would become
reservoir 1 release for ecosystem health =
LOOKUP FUNCTION OF SOME KIND (reservoir 1 array, weather classification, month)
Am I completely misunderstanding the purpose of tabbed arrays? If not, how do I read the release out of the tabbed array?
Thanks in advance for your help!
reading a value from a tabbed array
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: reading a value from a tabbed array
Unfortunately there is no in-built function, but I have added a model that allows you to do this.
You use SUM to loop over the elements in the array, and select the correct one.
You use SUM to loop over the elements in the array, and select the correct one.
- Attachments
-
- TABBED ARRAY select element.mdl
- (2.84 KiB) Downloaded 216 times
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: reading a value from a tabbed array
There are probably other ways to arrange things, using VECTOR ELM MAP for example.
/*
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: reading a value from a tabbed array
I'm using the sum/loop solution.
Thanks!
Thanks!