Allocate by priority

Use this forum to post Vensim related questions.
Post Reply
JozefSL
Junior Member
Posts: 8
Joined: Tue Apr 19, 2005 3:49 am

Allocate by priority

Post by JozefSL »

I am having a hard time with the "allocate by priority fnction" with multiple subscripts. I am building a power model, in which for each region I have a subscript for different efficiency and different fuels. So there are three subscripts (Region,Efficiency,Fuel). The plants with the least cost (a combination of efficiency and fuel cost) will meet the load in a particular region.
It appears that the order of subscripts is critical, and "SIZE" is killing me. It seems that size can be subscripted, but that does not make logic. But since the subscript have different size, sometimes I get error when smaller subscript is at the end. But even if I reorder the subsripts, and use the subscripted size to reflect the size of the vectors the allocation result is not correct. In a simple example I have a power load of 200MW. In two different fuel groups I have three power plants with cummulative power generation of 270MW. Allocated power, however, just add them up.

I would really appreciate any help on this function. Many thanks. Jozef
Attachments
Allocate by priority function.mdl
(2.18 KiB) Downloaded 433 times
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Post by Administrator »

I hope I am right here, it has been a while since I used the allocation functions in Vensim.

SIZE should always be the size of the last subscript element in the list. In your example, the safest thing is to use ELMCOUNT(ppl).

The allocate function works on a vector. When you have a multiple subscripted variable, you effectively have multiple vectors, but the size of each vector does not actually change.

In your example, does each power plant only use one fuel and one efficiency? If yes, then you can simplify the allocation and use something like

Allocation to plant[plant] = ALLOCATE BY PRIORITY (
capacity[plant]
, cost[plant]
, elmcount(plant)
, WIDTH
, demand across region )

This will allocate capacity from each plant by priority of its cost, and try and meet the total demand. You already know the ‘efficiency’ and ‘fuel’ so you can calculate some measure of ‘cost’ which becomes the priority.

Tony.
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Post by Pruyn »

I think it is important to mention that allocate by priority only works over 1 subscript, the last one in the row.
So you might need a step in between to come to one measurement. Like Tony describes above.

Jeroen
JozefSL
Junior Member
Posts: 8
Joined: Tue Apr 19, 2005 3:49 am

Post by JozefSL »

Thanks Tony and Jeroen. Your help is really appreciated. From your comments, I was able to make the function work. The attachment has a simple example of the corrected function with two subscripts [PowerRegions] and [PowerPlants]. The allocation logic is executed on the last script [PowerPlants] or for short [PP]. While it would be nice to have a function that would do the allocation over two dimensional arrays, this one will work for now. However, there is one more trick with this configuration. Not having the option for two dimensional arrays, I must list all the power plants in a region within the last subscript. I am used to input data to Vensim from Excel, and because the power plants must be in the last script, they must be in columns. Since there are only 256 columns, I can have only 256 power plants or figure out how to input data to Vensim in a different way. Does anyone have suggestion or solution?

Many thanks, Jozef
Attachments
Allocate by priority function.mdl
(2.09 KiB) Downloaded 404 times
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

allocation working with one subscript

Post by LAUJJL »

There are other functions that work only with the last subscript, for instance ordering an array on one subscript (Vector sort order).

If you want to work on several subscripts, the solution is to transform two subscripts into one and after having done the job, retransform if necessary the one subscript back into two. I think that I gave already an example how to do that in last posts.
I am actually busy, but if you do not know how to do it , look at older posts if you can find it. Otherwise I will try to send you the solution.
Regards.
J.J. Laublé
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

working with two subscripts

Post by LAUJJL »

Here is joined a very simple model that transforms an array with two subscripts and 6 values into a vector of one subscript with the same number of values.
Regards.
J.J. Laublé
Attachments
2dim_1dim.mdl
(1.35 KiB) Downloaded 410 times
JozefSL
Junior Member
Posts: 8
Joined: Tue Apr 19, 2005 3:49 am

Post by JozefSL »

J.J. Lauble', that is a cool way to change the array to a vector. This is very helpful. Is there a way back to take the vector and make the same array? Looking at the equation of “Vector Elm Map” I assume that the array’s “n1” and “m1” are the first members of the subscript. I see “subscript3” is the new vector, but why is the offset (subscript3-1)? What is the logic for “-1”?
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Array to vector

Post by LAUJJL »

Hi

The equation is
VECTOR ELM MAP( Array[n1,m1] , (subscript3 - 1))

The value subscript3 - 1 is the offset.
The offset is the number of positions starting from the beginning of the array needed to be translated through to get to the value corresponding to the vector.
So for instance for the first value of the subscript subscript3 which is K1, the corresponding value in the array is the first value of the array which is array(n1.m1). That value does not need any translation then requires an offset of 0.
Or susbscript3 for the first value of that subscript is equal to 1. And 1 - 1 is equal to 0. Then there is no translation.
The same reasoning works for the second subscript3 which is equal to 2, 2 - 1 = 1 and the first value of the array is shifted one position.
You should with this explanation and a little of brain working be able to construct the 1 dimension to 2 dimension back formula.
If you have any problem, post your question.
Regards.
J.J. Laublé
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

1 dim to 2 back model

Post by LAUJJL »

Joined the formulation back
Regards.
J.J. Laublé
Attachments
1dim_2dim.mdl
(1.37 KiB) Downloaded 407 times
Pruyn
Senior Member
Posts: 80
Joined: Fri Mar 05, 2004 2:34 pm

Post by Pruyn »

To get back to your earlier post, if I'm not mistaken vensim can "transpose" your matrix for you. Just use:

After[region,pp] = Before[pp,region]

You can than use before to input excel as you like with the max of 65536 rows for excel. Although I wouldn't know why you would need more than 256 power plants per region.

Jeroen
JozefSL
Junior Member
Posts: 8
Joined: Tue Apr 19, 2005 3:49 am

Thank You

Post by JozefSL »

Foremost “Thank You” for every comment I got on this problem. Not only you help me to solve the problem, but also you showed me more interesting things, which will come handy in the future.
J.J. Lauble’, I have downloaded the 1dim_2dim file, but it seems to be the same as the former 2dim_1dim file. Based on your comments, I looked at the definition of the “Vector Elm Map” and still am not absolutely clear about the logic, especially, how to script a triple script into one vector and vise versa.
Finally, there is one NERC (North American Electricity Reliability Council) region that has more than 256 fossil fuel power plants. And even though you can make it work with 256, it is much easier to read, check, or work with the information in rows rather than in columns. Just for the reference, I attached a simple example in which I tested and confirmed how the transformation works.
Attachments
Sub2x3_2_Sub3x2.mdl
(1.32 KiB) Downloaded 403 times
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Array to vector and vector to array

Post by LAUJJL »

Hi

joined the model that transforms an array to a vector and retransforms the vector back to an array.
J.J. Laublé
Attachments
2dim_1dim_2dim.mdl
(1.63 KiB) Downloaded 422 times
LAUJJL
Senior Member
Posts: 1421
Joined: Fri May 23, 2003 10:09 am
Vensim version: DSS

Array to vector

Post by LAUJJL »

Hi

If you look at the definition of the vector elm map it has at the end an example of how to get the value of an element in a three dimensions array, using the vector elm map function.
This explains exactly the exact offset of any element in this array.
If you cannot transform a three dimensionnal array into a vector and back, tell me I will give you the answer.
About your power plants, I do not understand your problem, as your model makes a simple transposition of a matrix 3X2 into a 2X3.
Regards.
J.J. Laublé
JozefSL
Junior Member
Posts: 8
Joined: Tue Apr 19, 2005 3:49 am

Post by JozefSL »

J.J. Lauble', I was not aware that Vensim can transform the subscripts so easily. Yes, now there is no problem. Sorry if that was not clear.

Jozef
Post Reply