saving variable values in Epsilon Constrained method

Hi,
I’m using Augmented Epsilon Constraint method based on the provided code on GAMS site http://www.gams.com/modlib/libhtml/epscm.htm .

My problem is that this code only saves the objective functions while I want my variable values X and Y be also saved.
The instructions for saving variables is as follows but I can’t understand it:

“Line 214: In the output building section of the code, beside the values of the objective functions the
user may add any other decision variable that wish to record for every efficient solution. In this case it
is recommended to appropriately add labels to the label row in line 195.”

193 * Walk the grid points and take shortcuts if the model becomes infeasible
194 posg(km1) = 0;
195 repeat
196 rhs(km1) = sum(grid(km1,g)(numg(g)=posg(km1)), gridrhs(km1,g)); 197 solve mod_epsmethod maximizing a_objval using lp; 198 if (mod_epsmethod.modelstat1, // not optimal is in this case infeasib le 199 lastZero = 0; loop(km1(posg(km1)>0 and lastZero=0), lastZero=numk(km1
));

214 loop(k, put ‘,’ k.tl:0); putclose ‘\n"); }’ / ‘{ print NR,$0 }’ / ‘END { p
rint “;” }’;
216 execute ‘cd "C:\Users\LOTUSLAPTOP.COM\Documents\gamsdir\projdir\225c" &&
gsort p.dat | uniq | awk -f awk.dat > g.dat && gams g.dat o=gx.dat lo=0 gd
x=soleps’;
217 execute ‘mv -f “C:\Users\LOTUSLAPTOP.COM\Documents\gamsdir\projdir\225c\so
leps.gdx” .’;

Anyone knows how to save variables??


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.

Hi Mesi Rahvar,

I think you could do this in order to print auxiliary variables x, y, etc in a text file together with the objectives z:



Instead of:

loop(k, put fx z.l(k):12:2); put /);



Put these lines in the gams program:


\

  1. File fx / MyOutputFile.txt /; (somewhere in your GAMS program, not inside the loop)


    \
  • now print extra info, not only z.l(k), but also x.l(p), y.l(p) etc.

  • assume a set p is defined for variables x and y


    \

  • print info about current solution

loop(k, put fx z.l(k):12:2);

put fx ’ *** ';

loop(p, put fx x.l(p):3:0);

put fx ’ *** ';

loop(p, put fx y.l(p):3:0);

put fx ’ *** ';



put /;

  • end print info about current solution



    The lines in 2 would print values for x and y after having printed values for objectives z.



    Maybe, you would like to consult a newer version of epscm.gms (AUGMECON) which is epscmmip.gms (AUGMECON2), also available in

https://sites.google.com/site/kflorios/augmecon2 and also in the GAMS model library http://www.gams.com/modlib/libhtml/epscmmip.htm

AUGMECON2 is specific for Multiobjective (Mixed) Integer Programming problems.



In the former website there are GAMS files which you could alter to implement what I suggested above, using a file fx and the put statements I suggested.



Best,

Kostas Florios



Kostas Florios

PhD Operational Research

MSc Computational Mechanics

Chemical Engineer NTUA

http://sites.google.com/site/kflorios/

From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of mesi.rahvar@gmail.com
Sent: Wednesday, February 04, 2015 7:28 PM
To: gamsworld@googlegroups.com
Subject: saving variable values in Epsilon Constrained method



Hi,

I’m using Augmented Epsilon Constraint method based on the provided code on GAMS site http://www.gams.com/modlib/libhtml/epscm.htm .



My problem is that this code only saves the objective functions while I want my variable values X and Y be also saved.

The instructions for saving variables is as follows but I can’t understand it:



"Line 214: In the output building section of the code, beside the values of the objective functions the

user may add any other decision variable that wish to record for every efficient solution. In this case it
is recommended to appropriately add labels to the label row in line 195."



193 * Walk the grid points and take shortcuts if the model becomes infeasible

194 posg(km1) = 0;

195 repeat

196 rhs(km1) = sum(grid(km1,g)$(numg(g)=posg(km1)), gridrhs(km1,g));

197 solve mod_epsmethod maximizing a_objval using lp;

198 if (mod_epsmethod.modelstat1, // not optimal is in this case infeasib

le

199 lastZero = 0; loop(km1$(posg(km1)>0 and lastZero=0), lastZero=numk(km1

));


214 loop(k, put ‘,’ k.tl:0); putclose ‘\n"); }’ / ‘{ print NR,$0 }’ / 'END { p

rint “;” }';

216 execute 'cd "C:\Users\LOTUSLAPTOP.COM\Documents\gamsdir\projdir\225c" &&

gsort p.dat | uniq | awk -f awk.dat > g.dat && gams g.dat o=gx.dat lo=0 gd

x=soleps’;

217 execute 'mv -f "C:\Users\LOTUSLAPTOP.COM\Documents\gamsdir\projdir\225c\so

leps.gdx" .';



Anyone knows how to save variables??


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.

Hi Mesi Rahvar,
I think you could do this in order to print auxiliary variables x, y, etc in a text file together with the objectives z:

Instead of:
loop(k, put fx z.l(k):12:2); put /);

Put these lines in the gams program:

  1. File fx / MyOutputFile.txt /; (somewhere in your GAMS program, not inside the loop)

  • now print extra info, not only z.l(k), but also x.l(p), y.l(p) etc.

  • assume a set p is defined for variables x and y

  • print info about current solution
    loop(k, put fx z.l(k):12:2);
    put fx ’ *** ';
    loop(p, put fx x.l(p):3:0);
    put fx ’ *** ';
    loop(p, put fx y.l(p):3:0);
    put fx ’ *** ';

put /;

  • end print info about current solution

The lines in 2 would print values for x and y after having printed values for objectives z.

Maybe, you would like to consult a newer version of epscm.gms (AUGMECON) which is epscmmip.gms (AUGMECON2), also available in
https://sites.google.com/site/kflorios/augmecon2 and also in the GAMS model library http://www.gams.com/modlib/libhtml/epscmmip.htm
AUGMECON2 is specific for Multiobjective (Mixed) Integer Programming problems.

In the former website there are GAMS files which you could alter to implement what I suggested above, using a file fx and the put statements I suggested.

Best,
Kostas Florios

Kostas Florios
PhD Operational Research
MSc Computational Mechanics
Chemical Engineer NTUA
http://sites.google.com/site/kflorios/


On Wednesday, February 4, 2015 at 7:28:23 PM UTC+2, mesi....@gmail.com wrote:

Hi,
I’m using Augmented Epsilon Constraint method based on the provided code on GAMS site http://www.gams.com/modlib/libhtml/epscm.htm .

My problem is that this code only saves the objective functions while I want my variable values X and Y be also saved.
The instructions for saving variables is as follows but I can’t understand it:

“Line 214: In the output building section of the code, beside the values of the objective functions the
user may add any other decision variable that wish to record for every efficient solution. In this case it
is recommended to appropriately add labels to the label row in line 195.”

193 * Walk the grid points and take shortcuts if the model becomes infeasible
194 posg(km1) = 0;
195 repeat
196 rhs(km1) = sum(grid(km1,g)(numg(g)=posg(km1)), gridrhs(km1,g)); 197 solve mod_epsmethod maximizing a_objval using lp; 198 if (mod_epsmethod.modelstat1, // not optimal is in this case infeasib le 199 lastZero = 0; loop(km1(posg(km1)>0 and lastZero=0), lastZero=numk(km1
));

214 loop(k, put ‘,’ k.tl:0); putclose ‘\n"); }’ / ‘{ print NR,$0 }’ / ‘END { p
rint “;” }’;
216 execute ‘cd "C:\Users\LOTUSLAPTOP.COM\Documents\gamsdir\projdir\225c" &&
gsort p.dat | uniq | awk -f awk.dat > g.dat && gams g.dat o=gx.dat lo=0 gd
x=soleps’;
217 execute ‘mv -f “C:\Users\LOTUSLAPTOP.COM\Documents\gamsdir\projdir\225c\so
leps.gdx” .’;

Anyone knows how to save variables??


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.

Thanks for your answer

I tried the following code for original example of the code:
loop(k, put fx z.l(k):12:2)
put fx ‘‘;
loop((p,i), put fx x.l(p,i):0:0);
put fx’
’;
put /);

But the solution reads :
---- 223 PARAMETER solutions Unique solutions

( ALL 0.000 )
I also changed the second loop as x.l(p,i):3:0) and it did not give me the answer neither. where am I wrong?
Thanks in advance.



On Thursday, February 5, 2015 at 3:25:37 PM UTC+3:30, Kostas Florios wrote:

Hi Mesi Rahvar,
I think you could do this in order to print auxiliary variables x, y, etc in a text file together with the objectives z:

Instead of:
loop(k, put fx z.l(k):12:2); put /);

Put these lines in the gams program:

  1. File fx / MyOutputFile.txt /; (somewhere in your GAMS program, not inside the loop)

  • now print extra info, not only z.l(k), but also x.l(p), y.l(p) etc.

  • assume a set p is defined for variables x and y

  • print info about current solution
    loop(k, put fx z.l(k):12:2);
    put fx ’ *** ';
    loop(p, put fx x.l(p):3:0);
    put fx ’ *** ';
    loop(p, put fx y.l(p):3:0);
    put fx ’ *** ';

put /;

  • end print info about current solution

The lines in 2 would print values for x and y after having printed values for objectives z.

Maybe, you would like to consult a newer version of epscm.gms (AUGMECON) which is epscmmip.gms (AUGMECON2), also available in
https://sites.google.com/site/kflorios/augmecon2 and also in the GAMS model library http://www.gams.com/modlib/libhtml/epscmmip.htm
AUGMECON2 is specific for Multiobjective (Mixed) Integer Programming problems.

In the former website there are GAMS files which you could alter to implement what I suggested above, using a file fx and the put statements I suggested.

Best,
Kostas Florios

Kostas Florios
PhD Operational Research
MSc Computational Mechanics
Chemical Engineer NTUA
http://sites.google.com/site/kflorios/


On Wednesday, February 4, 2015 at 7:28:23 PM UTC+2, mesi....@gmail.com wrote:

Hi,
I’m using Augmented Epsilon Constraint method based on the provided code on GAMS site http://www.gams.com/modlib/libhtml/epscm.htm .

My problem is that this code only saves the objective functions while I want my variable values X and Y be also saved.
The instructions for saving variables is as follows but I can’t understand it:

“Line 214: In the output building section of the code, beside the values of the objective functions the
user may add any other decision variable that wish to record for every efficient solution. In this case it
is recommended to appropriately add labels to the label row in line 195.”

193 * Walk the grid points and take shortcuts if the model becomes infeasible
194 posg(km1) = 0;
195 repeat
196 rhs(km1) = sum(grid(km1,g)(numg(g)=posg(km1)), gridrhs(km1,g)); 197 solve mod_epsmethod maximizing a_objval using lp; 198 if (mod_epsmethod.modelstat1, // not optimal is in this case infeasib le 199 lastZero = 0; loop(km1(posg(km1)>0 and lastZero=0), lastZero=numk(km1
));

214 loop(k, put ‘,’ k.tl:0); putclose ‘\n"); }’ / ‘{ print NR,$0 }’ / ‘END { p
rint “;” }’;
216 execute ‘cd "C:\Users\LOTUSLAPTOP.COM\Documents\gamsdir\projdir\225c" &&
gsort p.dat | uniq | awk -f awk.dat > g.dat && gams g.dat o=gx.dat lo=0 gd
x=soleps’;
217 execute ‘mv -f “C:\Users\LOTUSLAPTOP.COM\Documents\gamsdir\projdir\225c\so
leps.gdx” .’;

Anyone knows how to save variables??


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.