Problem with subscripts being lost

Use this forum to post Vensim related questions.
Post Reply
Jack Harich
Senior Member
Posts: 68
Joined: Wed Sep 15, 2004 9:01 pm
Vensim version: DSS

Problem with subscripts being lost

Post by Jack Harich »

Vensim is an excellent SD modeling tool, the world standard, but I've run across a problem using the current version of DSS, version 8.2.1, on Windows 10, 64 bit.

When I add a second subscript, the first one disappears. When I add another one, the second one disappears. However, now all three are in the Subscripts list in the equation editor. This is a showstopper, as it makes it impossible to tune the model for the missing subscripts using the current selection in Subscript Control. Perhaps I'm missing something and doing something wrong?

On the same version of DSS, on a small test model I'm able to add a second subscript and it doesn't disappear.

I've attached a screen shot of the problem after the third subscript was added, as well as the model. As you can see, I'm converting sets of identical structures into fewer ones, using subscripts.

Thanks, Jack
Attachments
TransportV1 09 Problem report.mdl
(88.29 KiB) Downloaded 123 times
VensimSubscriptBugLosingRanges.png
VensimSubscriptBugLosingRanges.png (225.28 KiB) Viewed 2430 times
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: Problem with subscripts being lost

Post by tomfid »

I'm going to guess that these subranges are overlapping. For example, if you have:

Rural Trip : horse, walk
Urban Trip : bike, walk

They will collapse into a single entry because the shared "walk" element indicates that they're part of the same family.

If you visit the Subscript Control and click the "full" button in the corner, you'll be able to see the subrange/range relationships. However, the structure above won't work, because you need a master range. Adding:

All Trips : bike, horse, walk

will take care of that.
Jack Harich
Senior Member
Posts: 68
Joined: Wed Sep 15, 2004 9:01 pm
Vensim version: DSS

Re: Problem with subscripts being lost

Post by Jack Harich »

Thanks for the quick reply. So a range element name must be unique for the entire model? I don't recall seeing that in the documentation. Nor does the software complain if it's tried. Collapsing into a single entry without complaining is, to me, bad tool behavior. It's like units that don't match.

To explain, the model has 3 types of areas to live: urban, suburban, and rural. Each area type has the same 5 options for travel: public (bus), private (car), shared (car), bike, and walking. The model needs to calculate average trip cost for all permutations, which is 3 x 5 = 15. Since some input is dynamics, this must be done in the model rather than prior in a spreadsheet.

"Master range" returns no hits in the Vensim documentation.

The Full mode of Subscript Control shows Subranges of All, None, Suburban Trip, Urban Trip. The Available Elements are public, private, shared, bike, walk.

I wonder if my best solution is to use element name prefixes or suffixes to indicate urban, suburban, and rural, like "public_U". This would keep the subscripts conceptually simple. However, I suspect that because you understand master range, that is even better. Is there a model example of that approach somewhere, or some documentation? Thanks again, Jack
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: Problem with subscripts being lost

Post by tomfid »

Collapsing subranges into a single entry under the master range is the intended tool behavior. There's a new Subscript Control coming, which you can preview via Tools>Switch to New Sketch.

The challenge here is that the situation is fundamentally ambiguous, so it's difficult for the parser to determine what the user intends. It attempts to give an informative error message when you Check Model:

Code: Select all

bob:
	b,c,d
	~	
	~		|

fred:
	a,b,c
	~	
	~		|
yields:

Code: Select all

ERROR:       -d- is an element of -bob- which appears to be a subfamily of -fred-.    
             But -d- is not an element of the family -fred-.    
             Check for two uses of the same symbol.    
I'll take a look at the docs to see if we can clarify the constraint.
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: Problem with subscripts being lost

Post by tomfid »

In general, whether you want a single master range with overlapping subranges, or distinct ranges, depends on whether you'll ever use the master range. If, for example, you want to calculate SUM(distance[all trips!]) the master range would be convenient.

On the other hand, if rural and urban trips have distinct structures, you might instead want:

Rural Trip : horse, r_walk
Urban Trip : bike, u_walk

If you go the master range route, you can still define some structures for only the rural or urban subsets. I think a little extra memory will be allocated for the undefined elements, but that's unlikely to be much of a penalty.
Jack Harich
Senior Member
Posts: 68
Joined: Wed Sep 15, 2004 9:01 pm
Vensim version: DSS

Re: Problem with subscripts being lost

Post by Jack Harich »

Thanks so much Tom, I will explore this. I especially appreciate you high level design thoughts.

The new Subscripts Control sure solves the lots of tabs problem. It seems to handle subranges much more clearly. I actually could not understand these by reading the documentation, but I've not been using subscripts much.
tomfid
Administrator
Posts: 3808
Joined: Wed May 24, 2006 4:54 am

Re: Problem with subscripts being lost

Post by tomfid »

Exactly - kudos to Tony for creating the new control, I think (nothing to do with me).
Post Reply