Use subscript with existing variable and level in the model

Use this forum to post Vensim related questions.
Post Reply
Joe_ng
Junior Member
Posts: 9
Joined: Wed Sep 19, 2018 2:51 pm
Vensim version: DSS

Use subscript with existing variable and level in the model

Post by Joe_ng »

Hi,

I am new to Vensim. Please forgive if my question can be found in VENSIM manual book or already been answered somewhere in the forum.

I know that subscript can be used for constant data, but can it be used to simplify existing variables or levels within the model?

In my specific case, I have 3 stocks as 3 cost levels for 3 regions, and i want to rank these cost levels to decide which one is cheapest, the most expensive, and in-between. Currently I use IF THEN ELSE and MAX, MIN to decide, it works since I only have 3 variables to rank, but the equation is kind of really messy and complicated. So i thought that using VECTOR RANK would help me to simplify this. The use of VECTOR RANK requires subscript but I dont know how to create subscript consist of variables and levels already existing in my model.

Thank you so much and really appreciate your help.

Joe.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Use subscript with existing variable and level in the model

Post by Administrator »

Can you upload the model so we can take a look?
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
Joe_ng
Junior Member
Posts: 9
Joined: Wed Sep 19, 2018 2:51 pm
Vensim version: DSS

Re: Use subscript with existing variable and level in the model

Post by Joe_ng »

Administrator wrote: Wed Sep 19, 2018 3:25 pm Can you upload the model so we can take a look?
Thank you for your reply. Please find as attached my model. The problem I mentioned is in View 2 of the model.

Thanks so much for your time.

Best,
Joe
Attachments
China recycle rate v3.mdl
(32.28 KiB) Downloaded 184 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Use subscript with existing variable and level in the model

Post by Administrator »

And which are the three levels you want to min/max?

You usually use subscripts to replicate model structure. For example, if you have some model structure for a company, you would add the "company" subscript to that structure. This way, you can have 100s of companies, but a single structure in your model. Looking at your model, you could get rid of the three distinct recycle structures and just have one subscripted by "recycle location". I've uploaded a modified version of your model where I've created the subscripted structure. Have a look and see if it makes sense to you.
China recycle rate v3.mdl
(34.46 KiB) Downloaded 197 times
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
Joe_ng
Junior Member
Posts: 9
Joined: Wed Sep 19, 2018 2:51 pm
Vensim version: DSS

Re: Use subscript with existing variable and level in the model

Post by Joe_ng »

Administrator wrote: Wed Sep 19, 2018 3:45 pm And which are the three levels you want to min/max?

You usually use subscripts to replicate model structure. For example, if you have some model structure for a company, you would add the "company" subscript to that structure. This way, you can have 100s of companies, but a single structure in your model. Looking at your model, you could get rid of the three distinct recycle structures and just have one subscripted by "recycle location". I've uploaded a modified version of your model where I've created the subscripted structure. Have a look and see if it makes sense to you.
China recycle rate v3.mdl
Hi, I want to rank the "cost level of recycling" (I have created shadows in View 2) in each region to decide which one is cheapest, 2nd cheapest, and most expensive. The subscripted structure makes sense for me, however I dont know how to assign values in the levels I mentioned to the subscript range.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Use subscript with existing variable and level in the model

Post by tomfid »

You can select existing variables and use Edit>Set Subscripts to add dimensions to them. Or, you can just manually edit the equations one by one.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Use subscript with existing variable and level in the model

Post by Administrator »

Joe_ng wrote: Wed Sep 19, 2018 4:01 pmHi, I want to rank the "cost level of recycling" (I have created shadows in View 2) in each region to decide which one is cheapest, 2nd cheapest, and most expensive. The subscripted structure makes sense for me, however I dont know how to assign values in the levels I mentioned to the subscript range.
In the small bit of structure I created, you would call VECTOR RANK and pass "Cost level of recycling[recycle location]" to it. This would then rank CHINA,EU,OTHER for you.
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
Joe_ng
Junior Member
Posts: 9
Joined: Wed Sep 19, 2018 2:51 pm
Vensim version: DSS

Re: Use subscript with existing variable and level in the model

Post by Joe_ng »

tomfid wrote: Wed Sep 19, 2018 4:13 pm You can select existing variables and use Edit>Set Subscripts to add dimensions to them. Or, you can just manually edit the equations one by one.
Thank you. That really helps!
Joe_ng
Junior Member
Posts: 9
Joined: Wed Sep 19, 2018 2:51 pm
Vensim version: DSS

Re: Use subscript with existing variable and level in the model

Post by Joe_ng »

Administrator wrote: Wed Sep 19, 2018 4:48 pm
Joe_ng wrote: Wed Sep 19, 2018 4:01 pmHi, I want to rank the "cost level of recycling" (I have created shadows in View 2) in each region to decide which one is cheapest, 2nd cheapest, and most expensive. The subscripted structure makes sense for me, however I dont know how to assign values in the levels I mentioned to the subscript range.
In the small bit of structure I created, you would call VECTOR RANK and pass "Cost level of recycling[recycle location]" to it. This would then rank CHINA,EU,OTHER for you.
Thanks much, but it got one problem: the initial value of the "COST LEVEL OF RECYCLING" can not be given different value for different regions (CHINA, EU OTHER). As in the picture below
Attachments
Capture.JPG
Capture.JPG (123.97 KiB) Viewed 6599 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Use subscript with existing variable and level in the model

Post by Administrator »

The best thing to do is to replace the "3" with a new constant called "INITIAL COST LEVEL OF RECYCLING"

For example, my subscript range "recycle location" is
EU,CHINA,OTHER COUNTRIES

New constant is
INITIAL COST LEVEL OF RECYCLING[recycle location]

and in the equation editor part, enter
3,4,5

Now when you run the model, the following will be active.
INITIAL COST LEVEL OF RECYCLING[EU] = 3
INITIAL COST LEVEL OF RECYCLING[CHINA] = 4
INITIAL COST LEVEL OF RECYCLING[OTHER COUNTRIES] = 5
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
Joe_ng
Junior Member
Posts: 9
Joined: Wed Sep 19, 2018 2:51 pm
Vensim version: DSS

Re: Use subscript with existing variable and level in the model

Post by Joe_ng »

Well suddenly my Vensim DSS 6.1c version crash every time i click the EQUATIONS editor...
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Use subscript with existing variable and level in the model

Post by Administrator »

Does it only happen with the model you are currently using? If yes, can you upload the model (or email it to vensim@vensim.com) and I'll try it here?
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
Joe_ng
Junior Member
Posts: 9
Joined: Wed Sep 19, 2018 2:51 pm
Vensim version: DSS

Re: Use subscript with existing variable and level in the model

Post by Joe_ng »

No, it happens to every models. I think the problem arise from the software. I sent an email already. Thank you for your help!
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Use subscript with existing variable and level in the model

Post by Administrator »

If it's all models, can you email your vensim.ini file to us (you can find it by pasting %APPDATA%\vensim into a Windows explorer window).

Please make sure you include your licence details when emailing.
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
Joe_ng
Junior Member
Posts: 9
Joined: Wed Sep 19, 2018 2:51 pm
Vensim version: DSS

Re: Use subscript with existing variable and level in the model

Post by Joe_ng »

Hi, i sent an email to vensim@vensim.com already. Please have a look. thanks
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Use subscript with existing variable and level in the model

Post by Administrator »

Have you moved from a multi monitor setup to a single monitor?
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: Use subscript with existing variable and level in the model

Post by Administrator »

See the following for a solution (this worked for me).
viewtopic.php?f=2&t=4828&p=16700&hilit=EqedDim1#p16700
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
Joe_ng
Junior Member
Posts: 9
Joined: Wed Sep 19, 2018 2:51 pm
Vensim version: DSS

Re: Use subscript with existing variable and level in the model

Post by Joe_ng »

Administrator wrote: Thu Sep 20, 2018 11:39 am See the following for a solution (this worked for me).
viewtopic.php?f=2&t=4828&p=16700&hilit=EqedDim1#p16700
oh thank you that what i was looking for. i have been using 2 monitors.
Post Reply