Subscript rule - subscripts on right hand side and left hand side

Use this forum to post Vensim related questions.
Post Reply
WayneZhou2009
Senior Member
Posts: 105
Joined: Wed Oct 25, 2017 3:52 pm
Vensim version: PRO

Subscript rule - subscripts on right hand side and left hand side

Post by WayneZhou2009 »

Hi, I am struggling with the ERROR message saying Subscript Range - XXX - appears on the right, but not left.

Vensim Help does say that "The most important subscript rule is that a subscript appearing on the right hand side of an equation must also appear on the left hand side. "

However, the AGE model in the EXTRA folder of sample models of Vensim (version Vensim Pro 7.1) seems to be against this rule. The level variable Population is defined as:

Population [all but youngest] = aging [previous cohort] - aging [all but youngest]. This model is working properly. It is attached here.

But, I have developed a model in which a variable is defined in a similar way to the Population in the AGE model, i.e. the subscript on its equation's right hand side does NOT appear on its left side. However, the ERROR message prompts.

So what is the reason? Is there any way around the restriction of the rule?

Thank you so much.

WZ
Attachments
AGE.MDL
(3.07 KiB) Downloaded 248 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Subscript rule - subscripts on right hand side and left hand side

Post by Administrator »

The model you've uploaded works fine for me. Where is the error?
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
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Subscript rule - subscripts on right hand side and left hand side

Post by Administrator »

The age model is not against the rule, it uses subscript mapping.

It's not really a "rule" either. For example, if you have a subscript range "company" and are looking at sales, you might have

sales[company,widget] = number of widgets sold[company,widgets] * cost per widget[widget]

If you want the total sales for the company, you would use
total sales[company] = sum ( sales[company,widget!] )

I cannot do
total sales[company] = sales[company,widget]
as I haven't done anything with the "widget" subscript range. I need to sum over the range, or get the max/min/whatever. If it's on the right of the equation, it must also appear on the left.

Hope this makes sense.
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
WayneZhou2009
Senior Member
Posts: 105
Joined: Wed Oct 25, 2017 3:52 pm
Vensim version: PRO

Re: Subscript rule - subscripts on right hand side and left hand side

Post by WayneZhou2009 »

Thanks a lot. The example given by you is clear, and explains the issue. However, in the above-mentioned AGE model, I cannot see where the subscript mapping has been done. Please could you enlighten me a bit further? Thanks.
Administrator wrote:The age model is not against the rule, it uses subscript mapping.

It's not really a "rule" either. For example, if you have a subscript range "company" and are looking at sales, you might have

sales[company,widget] = number of widgets sold[company,widgets] * cost per widget[widget]

If you want the total sales for the company, you would use
total sales[company] = sum ( sales[company,widget!] )

I cannot do
total sales[company] = sales[company,widget]
as I haven't done anything with the "widget" subscript range. I need to sum over the range, or get the max/min/whatever. If it's on the right of the equation, it must also appear on the left.

Hope this makes sense.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Subscript rule - subscripts on right hand side and left hand side

Post by Administrator »

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
WayneZhou2009
Senior Member
Posts: 105
Joined: Wed Oct 25, 2017 3:52 pm
Vensim version: PRO

Re: Subscript rule - subscripts on right hand side and left hand side

Post by WayneZhou2009 »

Thanks a lot. I missed the function of "->" in the sample model, which is the key to make possible the mapping.
Administrator wrote:It's all in the help system,
http://www.vensim.com/documentation/ind ... apping.htm
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Subscript rule - subscripts on right hand side and left hand side

Post by tomfid »

The enhanced rule is,

Anything that appears on the right:
- must appear on the left, or
- map to something on the left with ->
- be in a vector function like SUM with !
Post Reply