help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Emulating the AMPL ord() function


From: Meketon, Marc
Subject: Re: [Help-glpk] Emulating the AMPL ord() function
Date: Tue, 30 Dec 2014 16:28:22 -0600

While I understand your question, in the example that you gave do you really 
need ord(i) < ord(j), or can you suffice with  i < j  (which seems to work with 
your example)?  Often all you need is any consistent ordering and not 
necessarily a specific one.

-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Jason Foster
Sent: Saturday, December 27, 2014 2:14 PM
To: address@hidden
Subject: [Help-glpk] Emulating the AMPL ord() function

As part of shifting my group towards open source tools I've been working on 
converting some AMPL models to GMPL.  So far it's been working really well 
(thanks for some great work!) and I've just run into my first multi-hour snag.  
I've searched online and near as I can tell:

1) GMPL doesn't implement "ordered sets" (because "ordered" implies a 
mathematical ordering vs. the lexical ordering of the input text)
2) it is possible to work around some of these issues using a variety of 
techniques that require a reasonably deep understanding of GMPL

Regarding (2) there is a construct documented at 
http://lists.gnu.org/archive/html/help-glpk/2006-11/msg00059.html that I can't 
get to work as written:

set S;
param ref{i in 1..card(S)}, symbolic, in S; # ref[i] refers to i-th element of 
S; param a{S}; a[ref[i]] # means a[i-th element of S]

The error I get is that ref[i] is empty.

There is also a fairly involved discussion at 
http://en.wikibooks.org/wiki/GLPK/GMPL_Workarounds that addresses sorted 
output.  I poked at that for a bit and ran into some difficulties because I am 
looking for the lexical position within the set, not the result of a 
calculation.

The problem I am trying to solve is that I have the following data:

set PEOPLE := person01 person02 person03 person04;

param   exclude:        person01 person02 person03 person04 :=
        person01        0       1       0       0
        person02        1       0       0       1
        person03        1       0       0       1
        person04        0       1       1       0
;

exclude is "guaranteed" to be a symmetric matrix (assuming the generation code 
is working properly).  The AMPL code I have is trying to create:

set ALLOWED_PAIRS := {i in PEOPLE, k in PEOPLE: ( exclude[i, k] = 0 and 
exclude[k, i] = 0 ) and ( ord(i) < ord(k) )};

Of course this code doesn't work in GMPL because of the missing ord() function. 
 I believe that the goal is to precent the set from including redundant 
elements which will help keep the number of constraints down to something 
reasonable.

Based on what I've seen this should be a solvable problem using the tools 
available within GMPL but my current mental model isn't sufficient to work it 
out. I'm hoping that someone on the list can show a workaround and as such can 
help me continue the push to transition to a purely open source toolchain.

Thanks for any help or insights that you can offer!

Jason
_______________________________________________
Help-glpk mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-glpk

This e-mail and any attachments may be confidential or legally privileged. If 
you received this message in error or are not the intended recipient, you 
should destroy the e-mail message and any attachments or copies, and you are 
prohibited from retaining, distributing, disclosing or using any information 
contained herein.  Please inform us of the erroneous delivery by return e-mail. 
Thank you for your cooperation.



reply via email to

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