[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-glpk] [Fwd: GLPK printing with if and iterative loop (continued)]
From: |
Andrew Makhorin |
Subject: |
[Help-glpk] [Fwd: GLPK printing with if and iterative loop (continued)] |
Date: |
Sun, 20 Feb 2011 19:11:30 +0300 |
-------- Forwarded Message --------
From: Alan Zinober <address@hidden>
To: address@hidden
Subject: GLPK printing with if and iterative loop (continued)
Date: Sun, 20 Feb 2011 15:18:09 +0000
Oscar, many thanks for your assistance.
However, I think I actually need a sum ...
With your recommendation for my question below I used:
printf {i in Trainer, j4 in Course4, j5 in Course5, j6 in Course6:
x4[i,j4] + x5[i,j5] + x6[i,j6] = 0} "%s ",i;
to obtain:
A A A A B B B B C C D D D D E E G G H H H H I I I I J J J J K K
My Trainer set is A B C D E F G H I J K
In fact I wish to print
A B D G H I J
where i is printed only if there are 4 repeats above (when using your
recommendation).
i.e. for i iterating and for summing over the cases j4, j5, j6 jointly.
for Trainer i, if sum (iterating over j4, j5, j6) = 0, then print i.
eg printf (if x4[i,C41] + x4[i,C42] + x5[i,C51], + x5{i,C52] +
x5[i,C53] + x6[i,C61] = 0 then "%s "), i);
Why should this command below
for {i in Trainer}
printf (if sum{j4 in Course4} x4[i,j4]
+ sum{j5 in Course5} x5[i,j5]
+ sum{j6 in Course6} x6[i,j6] = 0 then "%s "),i;
print A B 0D 000H I J 0
I believe that the printout should be A B D H I J
I do not see why 0 is printed if the sum is not zero (for C, E, F, G,
K).
My Trainer set is A B C D E F G H I J K.
Alan
Alan
On 19/02/2011 21:40, Oscar Gustafsson wrote:
> Alan,
>
> the following should work:
>
> printf{i in Trainer, j4 in Course4, j5 in Course5, j6 in Course6:
> x4[i,j4] + x5[i,j5] + x6[i,j6] = 0} ...
>
> Regards
>
> Oscar
>
> Andrew Makhorin skrev 2011-02-19 22:26:
> > -------- Forwarded Message --------
> > From: Alan Zinober<address@hidden>
> > To: address@hidden
> > Subject: GLPK printing with if and iterative loop
> > Date: Sat, 19 Feb 2011 17:27:04 +0000
> >
> > I need to print the Trainer names only when
> >
> > x4[i,j4] + x5[i,j5] + x6[i,j6] = 0
> >
> > I declare:
> >
> > set Trainer; different trainer names
> >
> > set Course4; different course names
> > set Course5; different course names
> > set Course6; different course names
> >
> > var x4{Trainer, Course4}>=0, binary;
> > var x5{Trainer, Course5}>=0, binary;
> > var x6{Trainer, Course6}>=0, binary;
> >
> >
> > Essentially I need a print statement with the logic of the code
> > below
> > but do not know how to set up
> > j4 iterated on Course 4, j5 iterated on Course5, j6 iterated on
> > Course6 :
> >
> > for {i in Trainer}
> >
> > printf (if x4[i,j4 iterated on Course4] + x5[i,j5 iterated
> > on
> > Course 5]
> > + x6[i,j6 iterated on Course6] =0 then
> > "%s
> > "),Trainer[i];
> >
> > Alan
> >
> >
> >
> >
> >
> > _______________________________________________
> > Help-glpk mailing list
> > address@hidden
> > http://lists.gnu.org/mailman/listinfo/help-glpk
>
>
> _______________________________________________
> Help-glpk mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-glpk
- [Help-glpk] [Fwd: GLPK printing with if and iterative loop (continued)],
Andrew Makhorin <=