Vector lookup function

Use this forum to post Vensim related questions.
Post Reply
fel-vene
Junior Member
Posts: 10
Joined: Mon Dec 07, 2009 1:36 pm

Vector lookup function

Post 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!!
Felipe Venegas
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

This is a simple example that does what you want from the other thread.
Attachments
VectorLookup.mdl
(1.93 KiB) Downloaded 269 times
fel-vene
Junior Member
Posts: 10
Joined: Mon Dec 07, 2009 1:36 pm

Post 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!)!
Felipe Venegas
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

VECTOR LOOKUP was introduced in 5.6c so you won't be able to use it.
fel-vene
Junior Member
Posts: 10
Joined: Mon Dec 07, 2009 1:36 pm

Post by fel-vene »

Bob,

Thank you very much anyway.
Hope my saving let me buy the latest version this year ;)
Felipe Venegas
tomfid
Administrator
Posts: 3816
Joined: Wed May 24, 2006 4:54 am

Post 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
~
~ |
Post Reply