Subscript Subrange

Use this forum to post Vensim related questions.
Post Reply
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Subscript Subrange

Post by nikvyas » Thu Oct 17, 2019 8:50 am

Good morning/evening/afternoon.

It has been a while since I last posted here. But myself (and the Company I work for) are slowly but surely getting back into the use of Vensim.

I have a model that generates an aircraft flying programme. There are 100 aircraft (so I have a subscript called [aircraft] that has 100 elements) and the sorties are applied to any aircraft that is "available" at the time, using an ALLOCATE BY PRIORITY function. The aircraft then "take off" and, upon landing might be subject to corrective or preventative maintenance (making them unavailable for the duration of the maintenance). This works quite well. However:

The 100 aircraft might now be a combination of single seat and twin seat. They each have their own availability measure and one or two variables (such as MTBF) might also be different. However, they use the same maintenance etc. resource. So, they need to be identified separately. i.e, there needs to be a single seat flying programme that only single seat aircraft (such as a1 - a50) can fulfil and a twin seat flying programme that only twin seat aircraft (such as a51 - a100) are subject to. And the output (such as aircraft availability) needs to differentiate single seat availability and twin seat availability. However, after the aircraft have been allocated a sortie, they then follow the same maintenance route and share the same resources.

So, I was thinking if there is a subrange of the subscript that could be used? Single seat (a1 - a50) and twin seat (a51 - a100) and how the two are represented in subsequent equations. i.e, rather than a variable called "successfully assigned sorties[aircraft]" how would it be represented?

I can email the model (don't want to post it on here) if clarity is required.

Many thanks

Nik

tomfid
Administrator
Posts: 2782
Joined: Wed May 24, 2006 4:54 am

Re: Subscript Subrange

Post by tomfid » Thu Oct 17, 2019 5:50 pm

You can definitely use subranges for this.
https://www.vensim.com/documentation/22100.htm

I find it easiest to build them up hierarchically. For example:

single : (single1-single50)
twin : (twin1-twin50)
aircraft : single, twin

Then you can write distinct equations for maintenance[single] and maintenance[twin] where needed.

You can also use mapping to define parameters or other structure that applies to single & twin as a class. For example, create:

type : singleSeat, twinSeat -> (aircraft : single, twin)
x[type] = 1.5, 3.2

Then you can write:
z[aircraft] = y[aircraft] + x[type]

https://www.vensim.com/documentation/re ... apping.htm

nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Subscript Subrange

Post by nikvyas » Tue Oct 22, 2019 12:30 pm

Many thanks Tom.

I've tried your suggestion, but I think I am doing something fundamentally wrong. I have created 4 subranges as follows:

variant1 : (v1-v25)
variant2 : (v26-v50)
variant3 : (v51-v75)
variant4: (v76-v100)

Then:
aircraft: (variant1, variant2, variant3, variant4)

I have then created 4 specific flying programmes and used the ALLOCATE BY PRIORITY function for each of the subranges as follows:

successfully assigned v1[Variant1]=
ALLOCATE BY PRIORITY(available aircraft[Variant1], priority[Variant1] , ELMCOUNT(Variant1)
, width , flying programme with constraints v1)

successfully assigned v2[Variant2]=
ALLOCATE BY PRIORITY(available aircraft[Variant2], priority[Variant2] , ELMCOUNT(Variant2)
, width , flying programme with constraints v2)

successfully assigned v3[Variant3]=
ALLOCATE BY PRIORITY(available aircraft[Variant3], priority[Variant3] , ELMCOUNT(Variant3)
, width , flying programme with constraints v3)

successfully assigned v4[Variant4]=
ALLOCATE BY PRIORITY(available aircraft[Variant4], priority[Variant4] , ELMCOUNT(Variant4)
, width , flying programme with constraints v4)


So this seems to work OK so far.

I then want to combine them together for the subsequent sections of the model (corrective maintenance etc) as follows:

successful assigned sorties[Aircraft]=
successfully assigned v1[Aircraft]+successfully assigned v2[Aircraft]+successfully assigned v3[Aircraft]+successfully assigned v4[Aircraft]


But I get error messages as follows:
Used, not computed - successfully assigned v1(v26)
etc etc.

I figure there is something silly I have overlooked. Please help!

Thanks

Nik

Administrator
Super Administrator
Posts: 3392
Joined: Wed Mar 05, 2003 3:10 am

Re: Subscript Subrange

Post by Administrator » Tue Oct 22, 2019 12:38 pm

You'll need to create four equations to do this,

successful assigned sorties[variant1]=successfully assigned v1[variant1]
successful assigned sorties[variant2]=successfully assigned v2[variant2]
successful assigned sorties[variant3]=successfully assigned v3[variant3]
successful assigned sorties[variant4]=successfully assigned v4[variant4]

Use the "Add eq" button to create additional equations for "successful assigned sorties", and in the subscript box, make sure you put variant1 in the first equation.

Alternatively, if you delete the variable successful assigned sorties from your model, click View->As Text and paste in the following, it should work.

Code: Select all

successful assigned sorties[variant1]=successfully assigned v1[variant1] ~~|
successful assigned sorties[variant2]=successfully assigned v2[variant2] ~~|
successful assigned sorties[variant3]=successfully assigned v3[variant3] ~~|
successful assigned sorties[variant4]=successfully assigned v4[variant4]
	~	sortie
	~		|
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

nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Re: Subscript Subrange

Post by nikvyas » Tue Oct 22, 2019 1:18 pm

That's great, many thanks!

tomfid
Administrator
Posts: 2782
Joined: Wed May 24, 2006 4:54 am

Re: Subscript Subrange

Post by tomfid » Mon Oct 28, 2019 7:57 pm

I should mention that this kind of situation is potentially a good candidate for Ventity as well.

Post Reply