Page 1 of 1
Vector lookup function
Posted: Fri Jan 08, 2010 7:06 pm
by fel-vene
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!!
Posted: Sat Jan 09, 2010 11:46 am
by bob@vensim.com
This is a simple example that does what you want from the other thread.
Posted: Sun Jan 10, 2010 4:26 am
by fel-vene
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!)!
Posted: Sun Jan 10, 2010 1:29 pm
by bob@vensim.com
VECTOR LOOKUP was introduced in 5.6c so you won't be able to use it.
Posted: Sun Jan 10, 2010 4:04 pm
by fel-vene
Bob,
Thank you very much anyway.
Hope my saving let me buy the latest version this year

Posted: Fri Jan 22, 2010 6:39 pm
by tomfid
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
~
~ |