After the "solve" in GMPL, I wanted to display the duals of the constraints 
ARRIVALS, DEPARTURES using two different printf formats.

Ideally, it would have been nice to have written something like the below.  [As 
an aside, EVENTS is a set, but in reality I'm using the trick the Andrew showed 
us to sort the elements in EVENTS first by 'time' and then by 'ad', but that 
just complicates the example code below - however the fact that EVENTS is 
essentially sorted by time is why I want to interweave the 'arrivals' with the 
'departures'.]

Note in the example that the each printf has 2 expressions (time and a dual), 
but they appear in different order.  Below is what I would have liked to have 
had:

for{(time,ad) in EVENTS} {
  if ad='A' then printf "dual=%3g  %5d\n", ARRIVALS[time].dual, time

  else printf "          %5d dual=%3g\n", time, DEPARTURES[time].dual;
}

but that doesn't work.  The "if" statement isn't for execution of statement 
blocks, but only for returning a scalar.

My workaround was messy, and looks like:

for{(time,ad) in EVENTS} {
  printf
        if ad='A' then "dual=%3g  %5d\n" else "          %5d dual=%3g\n",
        if ad='A' then ARRIVALS[time].dual else time,
        if ad='A' then time else DEPARTURES[time].dual;
}

I would like to have the first alternative (or something like that) on a wish 
list of enhancements to GMPL.

Does anyone have a more clever (and more clear) work-around?

Thank you in advance,

-Marc

________________________________
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.
_______________________________________________
Help-glpk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to