Subscript position

Use this forum to post Vensim related questions.
Post Reply
Camila
Junior Member
Posts: 12
Joined: Tue Apr 21, 2009 8:45 pm

Subscript position

Post by Camila »

Hello,

Is there a function that allows me to get the subscript in a certain position? For instance:

I have the following subscript ranges
subMonth: (m1-m12)
subWD: (d0-d6)

and a variable: Demand(subMonth, subWD)

I would like to obtain the demand value for the current month (Month=GET TIME VALUE(1,0,3)) and day of the week (WDay=GET TIME VALUE(1,0,5)). So if Month=3 and WDay=5, I need Demand(m3,d5).

I know I can do this using IF THEN ELSE statements, but can I just refer to the subscripts position instead?

Thank you for your help :D ,
Camila
Administrator
Super Administrator
Posts: 4838
Joined: Wed Mar 05, 2003 3:10 am

Re: Subscript position

Post by Administrator »

You need to use a SUM outside of the if then else to create a loop.

First create some numeric value for the subscript range.

submonth id[submonth] = submonth
subWD ID[subWD] = subWD


now sum over the whole range, but only if month and week match.
sum ( IF THEN ELSE ( submonth id[submonth!] = month :and: subwd id[subwd!] = week , Demand[subMonth!, subWD!] , 0 ) )
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
Camila
Junior Member
Posts: 12
Joined: Tue Apr 21, 2009 8:45 pm

Re: Subscript position

Post by Camila »

Thank you! it works perfectly :)
tomfid
Administrator
Posts: 3995
Joined: Wed May 24, 2006 4:54 am

Re: Subscript position

Post by tomfid »

VECTOR ELM MAP is a more efficient way to implement this, though the difference will only matter in a large model.
Post Reply