sorting a parameter without losing their index and obtaining cumulative distribution

Archive of Gamsworld Google Group
Post Reply
Lucas
User
User
Posts: 2
Joined: 4 days ago

sorting a parameter without losing their index and obtaining cumulative distribution

Post by Lucas » 4 days ago

Hi guys

I want to sort parameter V without losing the index of parameters, then want to calculate the cumulative distribution according to sorted parameter.

I found GDXRANKExample18.gms code in GAMS Data Utilities library for sorting but this code deleted the parameter with same value, and changed the index too.

example

Code: Select all


set k/1*10/;
parameter  V(k)/1 15,2 27,3 12,4 8,5 4,6 9,7 23,8 3,9 10,10 15/;
, sorted_v(k),p(k),cumulative(k);
p(k)=1/card(k);
scalar b/0.6/
	Big_b
;


when I used GDXRANKExample18.gms the result is:

Code: Select all


1   3.000,    2   4.000,    3   8.000,    4   9.000,    5  10.000,    6  12.000
7  15.000,    8  15.000,    9  23.000,    10 27.000
but I want to have

Code: Select all

8 3, 5 4, 4 8, 6 9, 9 10, 3 12, 1 15, 10 15, 7 23 , 2 27


I want to code sorted_V ,cumulative and Big_b to get the following result:

Code: Select all

sorted_v(k)={8 3, 5 4, 4 8, 6 9, 9 10, 3 12, 1 15, 10 15, 7 23 , 2 27}
cumulative(k)={8 0.1, 5 0.2, 4 0.3, 6 0.4, 9 0.5, 3 0.6, 1 0.7, 10 0.8, 7 0.9 , 2 1}
Big_b=12; ( big_b is the smallest value of the V(K)  that  cumulative(K) is bigger that b (here e.g. cumulative('3') =0.6>=b=0.6  then Big_b=12)  )


could anyone help me please?

Thanks!

Post Reply