[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Ordered sets in GMPL

From: xypron
Subject: Re: [Help-glpk] Ordered sets in GMPL
Date: Wed, 24 Dec 2008 05:32:05 -0800 (PST)

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

Here you can also download the full files.

Best regards


View this message in context:
Sent from the Gnu - GLPK - Help mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]