Hi Zhu
You could code this as follows:
parameter results(g,*);
repeat (
c=c+1;
solve prob using mip minimizing z;
results(g,t)$(ord(g) = c+1) = x.l(t) ;
results(g,“c”)$(ord(g) = c+1) = c + EPS;
until c=7
);
display results;
Note, that I added EPS, because in the first iteration, all results are zero, so it wouldn’t display in the table. Adding EPS (a very small value in Gams) will give you all entries.
I also added the value of c in the results, so I can check if it really is using the correct value of c in the loop. For this I added a * in the parameter definition of results, so I can put whatever I want here (t and “câ€).
Hope this helps
Renger
\
Renger van Nieuwkoop
Department of Management, Technology and Economics
Centre for Energy Policy and Economics
Swiss Federal Institute of Technology Zurich
Zürichbergstrasse 18, 8032 Zurich, Switzerland
Mobile: +41 79 818 53 73
E-Mail: rengerv@ethz.ch
Blog: http://blog.modelworks.ch
From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Songming Zhu
Sent: Tuesday, November 4, 2014 12:18 AM
To: gamsworld@googlegroups.com
Subject: Re: need help to output solution pool as a parameter
Hello,
my program below counts from 0 to 7 in binary (x.l varies from 000 to 111) in gams,
Now I want to collect the solutions of all the iteration to output a table parameter, which is
t1 t2 t3
g0 0 0 0
g1 0 0 1
g2 0 1 0
g3 0 1 1
g4 1 0 0
g5 1 0 1
g6 1 1 0
g7 1 1 1
how can I do in gams?
sets t /t1*t3/;
scalars c /-1/;
parameters b(t);
binary variables x(t);
variables z;
equations
obj
eq;
obj… z =e= sum(t,b(t)*x(t));
eq… z =e= c;
model prob /all/;
b(‘t1’)=1;
loop(t,
b(t+1)=2*b(t);
);
repeat (
c=c+1;
solve prob using mip minimizing z;
until c=7
);
display x.l
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
–
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.