Sort Order (for multivariable)
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Sort Order (for multivariable)
Hello everyone
I have another problem with my model. Attached is my model. I want to combine all marginal cost and rank it from lower to highest value.
I tried vector sort order, but it can only sort 1 variable.
Is there any other solution?
Thanks in advance, team.
I have another problem with my model. Attached is my model. I want to combine all marginal cost and rank it from lower to highest value.
I tried vector sort order, but it can only sort 1 variable.
Is there any other solution?
Thanks in advance, team.
- Attachments
-
- sort order.mdl
- (6.36 KiB) Downloaded 164 times
Re: Sort Order (for multivariable)
You'll have to combine the 4 subscripts into a single master subscript if you want to sort them in a single operation. Something like:
unit : coal unit, hydro unit, ...
Then writing equations just for a particular subset (coal unit for example) becomes somewhat clumsy because the equation editor will insert "unit" by default into equations. So, another option would be to create a dedicated dimension for the master sort, and use mapping to assign the match for coal unit, hydro unit, etc.
Sorting is a computationally expensive operation, so I would discourage it wherever possible. If the idea is to create a merit-order dispatch, you could achieve the same thing with the ALLOC functions or FIND ZERO.
unit : coal unit, hydro unit, ...
Then writing equations just for a particular subset (coal unit for example) becomes somewhat clumsy because the equation editor will insert "unit" by default into equations. So, another option would be to create a dedicated dimension for the master sort, and use mapping to assign the match for coal unit, hydro unit, etc.
Sorting is a computationally expensive operation, so I would discourage it wherever possible. If the idea is to create a merit-order dispatch, you could achieve the same thing with the ALLOC functions or FIND ZERO.
/*
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
*/
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
Sorry Tom, but i'm not clear with this. Done doing the master subscript, but i can't quite follow this part.tomfid wrote: ↑Mon Aug 10, 2020 2:03 pm
Then writing equations just for a particular subset (coal unit for example) becomes somewhat clumsy because the equation editor will insert "unit" by default into equations. So, another option would be to create a dedicated dimension for the master sort, and use mapping to assign the match for coal unit, hydro unit, etc.
Can you please once again explain this part once again.
Thank you so much, Tom.
Re: Sort Order (for multivariable)
I think it makes sense to ask first, why are we doing this? If I knew, I could give a more useful answer.
/*
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
*/
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
OK the idea is like this.
I will calculate the marginal cost for each units from each technology. (technology = coal, RE, gas, hydro) (unit = coal 1, coal 2, etc).
After that, i want to rank the marginal cost, starting from the lowest value up to the highest value. This is because later on, i'll use this rank to calculate the average marginal cost. Hence, i really need to do this rank/sort model.
I will calculate the marginal cost for each units from each technology. (technology = coal, RE, gas, hydro) (unit = coal 1, coal 2, etc).
After that, i want to rank the marginal cost, starting from the lowest value up to the highest value. This is because later on, i'll use this rank to calculate the average marginal cost. Hence, i really need to do this rank/sort model.
Re: Sort Order (for multivariable)
I'll ponder how exactly to do this.
However, averages are independent of order, so it seems unneccessary to sort. You could simply use something like SUM( marginal cost[unit!]*capacity[unit!] ) / SUM( capacity[unit!] ).
However, averages are independent of order, so it seems unneccessary to sort. You could simply use something like SUM( marginal cost[unit!]*capacity[unit!] ) / SUM( capacity[unit!] ).
/*
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: Sort Order (for multivariable)
Similarly, if you want the cost of the marginal plant, you can use something like VMAX( IF THEN ELSE( utilization[plant!]>0, cost[plant!], 0 ) )
/*
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
*/
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
I think i need to rephrase my sentence. The average marginal cost i'm talking about is not that literal average.
I really need to sort it out in order for me to do the next calculation hence the rank.
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
This is the overview of what i'm trying to model. I put it into flowchart view so that u can get the idea of what i'm tyring to do.
The idea is like that.
The idea is like that.
Re: Sort Order (for multivariable)
I would do something like this:
/*
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
*/
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
Hi Tom,
Sorry, i just get the time to read your reply. Thank you so much.
I will look over it and i'm sure u've been such a help, Tom
Sorry, i just get the time to read your reply. Thank you so much.
I will look over it and i'm sure u've been such a help, Tom
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
Hello Tom,
I'm so sorry that i keep on asking you on simple things. The model that you've shared with me is brilliant. That's what i've been having in my mind. Thanks so much for giving me the idea on how to do it.
But Tom, it has been almost a week, and i still cannot figure out on how you make the subrange from a subscript.
I tried to add re into unit type. But when i put re unit on the right hand side [coal,gas,hydro,re -> (unit:c unit,g unit,h unit,re unit)], it didn't work. It will end up having [coal,gas,hydro,re -> (unit:c unit,g unit,h unit)], instead without re unit.
I tried to find it on the net, the SD books that i have (Sterman & Morecroft), but i still couldn't get the idea.
I hope you don't mind to share with me on how you do that because i want to alter the model you shared a little bit according to my objective.
Once again, i'm sorry to bother you with this kind of issue.
Hope to hear from you soon.
Re: Sort Order (for multivariable)
I used subscript mapping: https://www.vensim.com/documentation/re ... apping.htm and subranges: https://www.vensim.com/documentation/22100.htm
You may find it helpful to switch to text view to see the raw subscript equations.
You may find it helpful to switch to text view to see the raw subscript equations.
/*
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
*/
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
Thank you so much for your respond, Tom. I've read that one. But i'll tried to read it again, thoroughly.tomfid wrote: ↑Tue Aug 18, 2020 4:07 pm I used subscript mapping: https://www.vensim.com/documentation/re ... apping.htm and subranges: https://www.vensim.com/documentation/22100.htm
You may find it helpful to switch to text view to see the raw subscript equations.
Thank you so much
Re: Sort Order (for multivariable)
coal,gas,hydro,re -> (unit:c unit,g unit,h unit) won't work, because you can't map 4 elements to 3 elements. Perhaps "re unit" doesn't exist as a member of "unit"?
/*
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: Sort Order (for multivariable)
There are at least two ways to create a subrange:
1. If you already have
unit : (u1-u9)
you can create
subunit : (u3-u6)
and it will automatically appear in the subrange list.
2. You can build them up hierarchically, by first defining
unit low : (u1-u4)
unit high : (u5-u9)
then merging those with:
unit : unit low, unit high
1. If you already have
unit : (u1-u9)
you can create
subunit : (u3-u6)
and it will automatically appear in the subrange list.
2. You can build them up hierarchically, by first defining
unit low : (u1-u4)
unit high : (u5-u9)
then merging those with:
unit : unit low, unit high
/*
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
*/
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
tomfid wrote: ↑Tue Aug 18, 2020 4:12 pm There are at least two ways to create a subrange:
1. If you already have
unit : (u1-u9)
you can create
subunit : (u3-u6)
and it will automatically appear in the subrange list.
2. You can build them up hierarchically, by first defining
unit low : (u1-u4)
unit high : (u5-u9)
then merging those with:
unit : unit low, unit high
And that seems much more clearer to me will try both and let you know if i success.
I can't thank you enough, Tom.
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
tomfid wrote: ↑Tue Aug 18, 2020 4:12 pm There are at least two ways to create a subrange:
1. If you already have
unit : (u1-u9)
you can create
subunit : (u3-u6)
and it will automatically appear in the subrange list.
2. You can build them up hierarchically, by first defining
unit low : (u1-u4)
unit high : (u5-u9)
then merging those with:
unit : unit low, unit high
Tom,
Thanks so much for your guidance. I have finally understand on how to do the mapping for subscript and the subranges. Like finally! Should have u earlier. once and for the nth time, Thank You so much!
Re: Sort Order (for multivariable)
Great! You're most welcome.
/*
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
*/
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
Hai Tom,
Here i am again, hoping that u can do me a favor.
I am still trying to understand the model that u have shared with me earlier.
But i couldn't get on how the model is doing. The output seems like it did what i want.
If you don't mind, can you please brief me a little bit especially on how "output" and "marginal cost" works.
Thanks in advance, Tom. Sorry to burden you.
Here i am again, hoping that u can do me a favor.
I am still trying to understand the model that u have shared with me earlier.
But i couldn't get on how the model is doing. The output seems like it did what i want.
If you don't mind, can you please brief me a little bit especially on how "output" and "marginal cost" works.
Thanks in advance, Tom. Sorry to burden you.
Re: Sort Order (for multivariable)
The documentation for the allocation process is here: https://www.vensim.com/documentation/al ... erview.htm
The basic idea is that the unit costs are used to construct an aggregate supply curve. Then it computes the market-clearing costs, where demand intersects that curve. Any plant below that cost runs, and plants above are idle.
The width parameter controls how much diversity is assumed in cost - if the width is small utilization is essentially a strict sequence. If it is large, the cutoff is soft - plants with similar costs near the margin will operate simultaneously with partial utilization.
The basic idea is that the unit costs are used to construct an aggregate supply curve. Then it computes the market-clearing costs, where demand intersects that curve. Any plant below that cost runs, and plants above are idle.
The width parameter controls how much diversity is assumed in cost - if the width is small utilization is essentially a strict sequence. If it is large, the cutoff is soft - plants with similar costs near the margin will operate simultaneously with partial utilization.
/*
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
*/
-
- Senior Member
- Posts: 80
- Joined: Sun Feb 02, 2020 5:10 am
- Vensim version: DSS
Re: Sort Order (for multivariable)
Thanks a lot, Tom!!tomfid wrote: ↑Tue Aug 25, 2020 4:11 pm The documentation for the allocation process is here: https://www.vensim.com/documentation/al ... erview.htm
The basic idea is that the unit costs are used to construct an aggregate supply curve. Then it computes the market-clearing costs, where demand intersects that curve. Any plant below that cost runs, and plants above are idle.
The width parameter controls how much diversity is assumed in cost - if the width is small utilization is essentially a strict sequence. If it is large, the cutoff is soft - plants with similar costs near the margin will operate simultaneously with partial utilization.