## optimal dual variables

Problems with syntax of GAMS
MAHMOUDRayan
User
Posts: 3
Joined: 1 year ago

### optimal dual variables

Hello,
Good time,

I wrote a source code, but I do not know how to use optimal dual variables in this source code?
How to write the optimal dual variables in this source code?

Thanks.

Code: Select all

``````SET
k     Number.    / 2000 * 2005 /
m     Number.    / 1 * 1 /
j     Number.    / 1 * 1 /
n     Number.    / 1 * 3 /
q                /1/

ALIAS(k,L);
ALIAS(c,L);

PARAMETERS

vv(m), ww(j), xx(n);

TABLE x(k,n)
1    2    3
2000        50   81   23
2001        21   52   20
2002        38   27   26
2003        44   55   33
2004        53   42   40
2005        75   22   47;

TABLE w(k,j)

1
2000           12
2001           12
2002           13
2003           13
2004           15
2005           15;

TABLE v(k,m)
1
2000            25
2001            26
2002            26
2003            28
2004            30
2005            32;

Table gv(m,q)
1
1          -1;

Table gw(j,q)
1
1           1;
FREE VARIABLe                z1,phi, piw(j);

POSITIVE VARIABLE
lan(j), piv(m), pix(n);
FILE                         EF2/newmodel/

EQUATION                     OBJECT1,CON1,CON2, con3;

OBJECT1..                   Z1=E=phi  ;

CON1(k).. (SUM(m,piv(m)*v(k,m))-SUM(j,piw(j)*w(k,j))+SUM(n,pix(n)*x(k,n)))-
(SUM(m,piv(m)*vv(m))-SUM(j,piw(j)*ww(j))+SUM(n,pix(n)*xx(n)))=l=phi;
CON2..     SUM(m,piv(m)*gv(m,"1"))+SUM(j,piw(j)*gw(j,"1"))=e=1;
Con3..     SUM(m,piv(m)*vv(m))-SUM(j,piw(j)*ww(j))+phi=g=0;

*----------------------------------------------------------------------------------------------
MODEL                new2  /all/;

PUT EF2;
LOOP(L,
LOOP(m,vv(m)=v(l,m)/SMAX(c,v(c,m)));
LOOP(j,ww(j)=w(l,j)/SMAX(c,w(c,j)));
LOOP(n,xx(n)=X(l,n)/SMAX(c,x(c,n)));

SOLVE new2 USING lp MINIMIZING Z1;
PUT \$(new2.modelstat EQ 1)'z1 ='z1.L:8:2;
PUT \$(new2.modelstat EQ 2)'z1 ='z1.L:8:2;
put \$(new2.modelstat Eq 4)" infeasible";
put \$(new2.modelstat Eq 3)" unbounded";
put/;
put "optimal phi= " phi.l:8:2;  put/;
loop(m, put "piv= " piv.l(m):18:10;  put/; )
loop(n, put "pix= " pix.l(n):18:10;  put/; )
loop(j, put "piw= " piw.l(j):18:10;  put/; )
put/;

);
``````

A.Sen
User
Posts: 2
Joined: 1 year ago

### Re: optimal dual variables

Hello.
You are looking for marginal variables in GAMS. So you could use Con1.m(k), Con2.m, Con3.m.
Sincerely,