Page 1 of 1

Subscript position

Posted: Fri Jun 12, 2015 12:04 pm
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

Re: Subscript position

Posted: Fri Jun 12, 2015 12:21 pm
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 ) )

Re: Subscript position

Posted: Fri Jun 12, 2015 12:53 pm
by Camila
Thank you! it works perfectly :)

Re: Subscript position

Posted: Sat Jun 13, 2015 11:56 pm
by tomfid
VECTOR ELM MAP is a more efficient way to implement this, though the difference will only matter in a large model.