Hello Andrew,

>> I would appreciate if a function to sort sets could be provided in GMPL.

I have implemented the possibility to sort sets in GLPK.

== Syntax ==

The syntax I have chosen is to add a keyword "sorted" to domains:
set B, dimen 2 := setof{sorted (i,j) in A} (i,j);

This syntax allows to sort by any sorting criteria like:
set C := setof{(k,l) in A} (k-l, k);
set D := setof{sorted (i,j) in C}j;
This example creates a set D containing the elements of the first column of
A sorted by the difference of the columns.

== Implementation Details ==

These are the changes:
In glpalv.h I have added a definition of avl_find_next_node() and changed
glpalv.c accordingly.
In glpmpl.h I have added a new token T_SORTED. I added a field sorted to
struct ARRAY.
In glpmpl.c I have added T_SORTED to the reserved keywords. The token is
used in indexing_expression() to set a flag sorted in struct ARRAY.
In glpmpl03.c I have added a new function sort_elemset() which first assures
that the AVL tree is build and then uses the tree to relink the MEMBERSs of
the set.

== Patches ==

Please, find the patches here:

old revision 377 - new revision 379

http://glpk.dyndns.org/viewvc/svn/glpk/glpk/branches/glpk-4.34-dot/include/glpavl.h?view=diff&r1=379&r2=377&diff_format=h
http://glpk.dyndns.org/viewvc/svn/glpk/glpk/branches/glpk-4.34-dot/include/glpmpl.h?view=diff&r1=379&r2=377&diff_format=h

http://glpk.dyndns.org/viewvc/svn/glpk/glpk/branches/glpk-4.34-dot/src/glpmpl03.c?view=diff&r1=379&r2=377&diff_format=h
http://glpk.dyndns.org/viewvc/svn/glpk/glpk/branches/glpk-4.34-dot/src/glpmpl01.c?view=diff&r1=379&r2=377&diff_format=h
http://glpk.dyndns.org/viewvc/svn/glpk/glpk/branches/glpk-4.34-dot/src/glpavl.c?view=diff&r1=379&r2=377&diff_format=h

Here you can also download the full files.

Best regards

Xypron

-- 
View this message in context: 
http://www.nabble.com/Ordered-sets-in-GMPL-tp21102805p21156845.html
Sent from the Gnu - GLPK - Help mailing list archive at Nabble.com.



_______________________________________________
Help-glpk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to