Please enable JavaScript to view this site.

Vensim Help

Using an equation with a Subscript Range is like using a "for" or "do" loop.  Although you do not need to specify this loop explicitly, the loop concept determines what you can and cannot do.  For example, consider the following equation:

births[country,income]  = 
frac_birth_rat[country,income] *
population[country,income] ~~|

This equation is really saying

for each country {USA,CANADA,MEXICO}
for each income {LOW,MIDDLE,HIGH}
 births[country,income]=
frac_birth_rat[country,income] *
population[country,income] ~~|
end for each income

end for each country

The equations for country and class determine the meaning of each country and each income as indicated by the comments.  

The Subscript Ranges on the left-hand side of an equation determine the implicit "for each" components.  Thus the equation

births[country,HIGH] =
frac_birth_rat[country,income] *
population[country,income] ~~|

would be wrong.  The left-hand side implies only a single "for each" loop on country, but the right-hand side requires one for country and one for income.  In this case, you will get a message reporting that the Subscript Range income appears on the right but not on the left of the equation.

Family mismatches are another common problem with subscripts.  All variables must have the same number of subscripts from the same family.  For example, the equation that contains both population[country] and population[country,income] will cause a problem since population must be broken down either by country, or by country and income.It cannot be broken down by country sometimes and by country and income  at other times.    

Even when the number of subscripts match, there can be problems if the families do not also match.  Suppose that population[country,income] appears in one place and population[country,region] in another.  It makes no sense for population to be broken down in two different ways, both by income and by region.