Subscript question:
If I have a subscript of Fruit with elements:
mandarins, satsumas, easy peelers, granny smith, red delicious, pink lady
subrange oranges: mandarins, satsumas, easy peelers
subrange apples: granny smith, red delicious, pink lady
Why can't I write an equation as follows:
Total Annual Fruit[Fruit] = SUM(total annual oranges[oranges!]) + SUM(total annual apples[apples!])
total annual oranges = average yield[oranges] * trees[oranges]
total annual apples = average yield[apples] * trees [apples]
subscripts
-
- Junior Member
- Posts: 16
- Joined: Mon May 08, 2023 8:34 am
- Vensim version: PRO
-
- Junior Member
- Posts: 16
- Joined: Mon May 08, 2023 8:34 am
- Vensim version: PRO
Re: subscripts
Ok, maybe that's because the LHS is Fruit but we summed everything up.
What about this:
Total Annual Fruit[Fruit] = total annual oranges[oranges] + total annual apples[apples]
If all the elements in Fruit are accounted for in the equation, via the 2 subranges, why does it return an error?
What about this:
Total Annual Fruit[Fruit] = total annual oranges[oranges] + total annual apples[apples]
If all the elements in Fruit are accounted for in the equation, via the 2 subranges, why does it return an error?
Re: subscripts
Your second equation has 6 elements on the left, and 2 instances of 3 elements on the right, so it can't work.
You could do something like the following:
oranges : mandarins, satsumas, easy peelers
apples : granny smith, red delicious, pink lady
fruit : oranges, apples ~ build the master list hierarchically
fruitType : o, a -> (fruit : oranges, apples) ~ this maps the 2 types to the 6 detailed types
total[o] = SUM( detail[oranges!])
total[a] = SUM( detail[apples!])
You could do something like the following:
oranges : mandarins, satsumas, easy peelers
apples : granny smith, red delicious, pink lady
fruit : oranges, apples ~ build the master list hierarchically
fruitType : o, a -> (fruit : oranges, apples) ~ this maps the 2 types to the 6 detailed types
total[o] = SUM( detail[oranges!])
total[a] = SUM( detail[apples!])
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: subscripts
The mapping lets you write stuff like:
sales[fruit] = preference[fruitType]*supply[fruit]
sales[fruit] = preference[fruitType]*supply[fruit]
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/