Efficient variable declaration on subranges

Use this forum to post Vensim related questions.
Post Reply
AurelienP
Junior Member
Posts: 7
Joined: Wed Jun 12, 2019 9:14 am
Vensim version: DSS

Efficient variable declaration on subranges

Post by AurelienP »

Good morning,
I have a question regarding declaration of variables with different definitions on different subranges.

Assuming we have a subscript family COUNTRY containing the following subscript elements: FRA, ITA, USA, CAN, with FRA and ITA contained in the subrange EU, whereas USA and CAN contained in the subrange NAM.

We want to define a variable VAR depending on COUNTRY.
Among the following suggestions, which one would work (or not), and which one would be the best way to go?
  1. VAR[EU] = x
    VAR[NAM] = y
  2. VAR[COUNTRY]:EXCEPT:[NAM] = x
    VAR[NAM] = y
  3. VAR[COUNTRY]= IF THEN ELSE(COUNTRY = EU, x, y)
  4. VAR[COUNTRY]= IF THEN ELSE(COUNTRY = FRA :OR: COUNTRY = ITA, x, y)
Thanks in advance!
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Efficient variable declaration on subranges

Post by Administrator »

All will work.

Personally, I would use option 1, I find that way to be the clearest, one equation for each subrange. I don't like using :EXCEPT: statements as it makes it just a little more difficult to figure out what equation is responsible for calculating something, especially if there are multiple :EXCEPT: statements.
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
AurelienP
Junior Member
Posts: 7
Joined: Wed Jun 12, 2019 9:14 am
Vensim version: DSS

Re: Efficient variable declaration on subranges

Post by AurelienP »

OK thanks. In terms of performance, no difference at all then?
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Efficient variable declaration on subranges

Post by Administrator »

No difference in terms of performance. I find it much clearer, but others could be different.
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
Post Reply