Hello!
I was wondering if anybody has a model who has a vector lookup function included that can upload because I tried to use this function in one of my models but I have not figured out how it works and the literature (webpages and manual) I revised have not helped me.. yet..
I would really appreciate it!!
Vector lookup function
Vector lookup function
Felipe Venegas
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
This is a simple example that does what you want from the other thread.
- Attachments
-
- VectorLookup.mdl
- (1.93 KiB) Downloaded 269 times
Thank you Bob,
I downloaded the model and it makes perfect sense now (refereing to the structure and the inputs). Just one observation: when I try to run it a compilation error appears: "Missing a closing parenthesis on a lookup table call"
The cursor points here(*):
var over time= VECTOR LOOKUP(vec[T1],*Time/Unit Month, INITIAL TIME/Unit Month, FINAL TIME/Unit Month, 2).
I tried, based on your example, some other examples that should work, but it allways appear the compilation error with the same message. I review the example explained on http://www.vensim.com/documentation/html/22779.htm
but even so I get the same message.
I am not sure but can it be because I am running Vensim DSS version 5.5b? I am running out of options that could explain what is happening :S
But anyways, thanks lot (again!)!
I downloaded the model and it makes perfect sense now (refereing to the structure and the inputs). Just one observation: when I try to run it a compilation error appears: "Missing a closing parenthesis on a lookup table call"
The cursor points here(*):
var over time= VECTOR LOOKUP(vec[T1],*Time/Unit Month, INITIAL TIME/Unit Month, FINAL TIME/Unit Month, 2).
I tried, based on your example, some other examples that should work, but it allways appear the compilation error with the same message. I review the example explained on http://www.vensim.com/documentation/html/22779.htm
but even so I get the same message.
I am not sure but can it be because I am running Vensim DSS version 5.5b? I am running out of options that could explain what is happening :S
But anyways, thanks lot (again!)!
Felipe Venegas
-
- Senior Member
- Posts: 1107
- Joined: Wed Mar 12, 2003 2:46 pm
You can create a vector lookup using subscripts. It's not as convenient, but works. Here's one approach (not necessarily the best way to do the interpolation, but it works):
interval weight[xNext]=
MAX(0,MIN(1, (x input-x vals[xPrev])/(x vals[xNext]-x vals[xPrev]) )) ~~|
interval weight[x1]=
1
~
~ |
vec:
(x1-x5)
~
~ |
x input=
Time
~
~ |
x vals[vec]=
10,25,30,35,50
~
~ |
x weight[xPrev]=
MIN(interval weight[xPrev],1-interval weight[xNext]) ~~|
x weight[x5]=
interval weight[x5]
~
~ |
xNext:
(x2-x5) -> xPrev
~
~ |
xPrev:
(x1-x4) -> xNext
~
~ |
y output=
SUM(x weight[vec!]*y vals[vec!])
~
~ |
y vals[vec]=
1,3,2,5,4
~
~ |
interval weight[xNext]=
MAX(0,MIN(1, (x input-x vals[xPrev])/(x vals[xNext]-x vals[xPrev]) )) ~~|
interval weight[x1]=
1
~
~ |
vec:
(x1-x5)
~
~ |
x input=
Time
~
~ |
x vals[vec]=
10,25,30,35,50
~
~ |
x weight[xPrev]=
MIN(interval weight[xPrev],1-interval weight[xNext]) ~~|
x weight[x5]=
interval weight[x5]
~
~ |
xNext:
(x2-x5) -> xPrev
~
~ |
xPrev:
(x1-x4) -> xNext
~
~ |
y output=
SUM(x weight[vec!]*y vals[vec!])
~
~ |
y vals[vec]=
1,3,2,5,4
~
~ |
/*
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
*/