[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Printing only non-zero output
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] Printing only non-zero output |
Date: |
Mon, 3 Nov 2008 11:57:21 +0300 |
> I'm a complete newbie to GLPK, but have battled through much of the early
> learning over the past week.
> I'm now trying to print my output in a sensible way - specifically, in
> the code below I want to print only days where I have bought something.
> As it is, I have commented out the bit where I tried to make it only
> print days where I buy something, so the model works, but it doesn't do
> what I want.
> If I un-comment out that line, it says "invalid use of reserved keyword
> if"
> Can someone please tell me how I should make GLPK do what I want it to
> do.
> printf "\nday\tadult\tchild\tsenior\n";
> for {d in day}:
> #if sum{t in ticket}buy[d,t] then
> {printf "%d\t%4.2f\t%4.2f\t%4.2f\n",d,
> buy[d,'adult'], buy[d,'child'], buy[d,'senior'];
> }
For example, like this:
printf "\nday\tadult\tchild\tsenior\n";
for {d in day : sum{t in ticket}buy[d,t]}
{ printf "%d\t%4.2f\t%4.2f\t%4.2f\n",d,
buy[d,'adult'], buy[d,'child'], buy[d,'senior'];
}