Hi folks.
I am dealing with this error but I could not find the related problematic part because the Gams is showing me wrong line for the error.
Could you please help me how can i solve this issue and run my model?
sets
i /1*10/;
alias(i,j);
sets
spr /1*10/;
sets
k 'objective functions' /maxP, minc/;
binary variable
x(i)
y(spr);
Parameter dir(k) direction of the objective functions 1 for max and -1 for min
/ maxp +1
minc -1
/;
variable
z(k) 'objective function variables';
scalar
Dmin /3/
Nmax /10/
Nmin /0/
;
parameter
a(i) x-coordinate of x(i) /
$call xls2gms r=a2:b11 i=kitap1.xlsx o=koordinatx.inc
$include koordinatx.inc
/;
parameter
b(i) y-coordinate of x(i) /
$call xls2gms r=e2:f11 i=kitap1.xlsx o=koordinaty.inc
$include koordinaty.inc
/;
parameter
d1(spr) x-coordinate of y(spr) /
$call xls2gms r=j2:k11 i=kitap1.xlsx o=koordinatx.inc
$include koordinatx.inc
/;
parameter
d2(spr) y-coordinate of y(spr) /
$call xls2gms r=n2:o11 i=kitap1.xlsx o=koordinaty.inc
$include koordinaty.inc
/;
parameter
m(i) big M;
m(i)=100000;
parameter
d(i,j) distance between i and j;
d(i,j)= sqrt(power((a(i)-a(j)),2)+power((b(i)-b(j)),2));
parameter
c(i,spr) distance between i and k;
c(i,spr)= sqrt(power((a(i)-d1(spr)),2)+power((b(i)-d2(spr)),2));
parameter
yeni(i,spr);
yeni(i,spr)$=(c(i,spr)<=5)=1;
parameter
n(i,j);
n(i,j)$(ord(i)<>ord(j) and d(i,j)<>0)= ((1 / power(d(i,j),3)));
variable
w(i);
w.l(i)= sum(j, (n(i,j)))-(0.1*sum(spr, yeni(i,spr)));
equations
obj1 'obj for maximizing p in K$'
obj2 'obj for minimizing c in Kt'
eq1
eq2
eq3
eq4
eq5
eq6
eq7
eq8
;
obj1.. sum(i, x(i)) =e= z('maxP');
obj2..sum(spr, y(spr))=e=z('minc');
*objfunc2..z2=e=sum(k, y(k));
eq1..sum(i,x(i))=g=Nmin;
eq2..sum(i,x(i))=l=Nmax;
eq3..sum(spr, y(spr))=l=10;
eq4..sum(spr, y(spr))=g=1;
eq5(i, j)$(ord(i) <> ord(j) and d(i, j) <= Dmin ).. x(i) + x(j) =l= 1;
eq6(i)..w(i)+0.1*sum(spr, yeni(i,spr))+m(i)*(1-x(i))=g=sum(j$(ord(i)<>ord(j) and d(i,j)<>0),(n(i,j))*x(j));
eq7(i)..w(i)=g=0;
eq8..sum(i, w(i))=l=2.042
*eq8..2*sum(k, y(k))=l=10;
Model example / all /;
*---------------------------------------------------------------------------
$STitle eps-constraint method
Set k1(k) the first element of k, km1(k) all but the first elements of k;
k1(k)$(ord(k)=1) = yes; km1(k)=yes; km1(k1) = no;
Set kk(k) active objective function in constraint allobj
Parameter
rhs(k) right hand side of the constrained obj functions in eps-constraint
maxobj(k) maximum value from the payoff table
minobj(k) minimum value from the payoff table
numk(k) ordinal value of k starting with 1
Scalar
iter total number of iterations
infeas total number of infeasibilities
elapsed_time elapsed time for payoff and e-sonstraint
start start time
finish finish time
Variables
a_objval auxiliary variable for the objective function
obj auxiliary variable during the construction of the payoff table
Positive Variables
sl(k) slack or surplus variables for the eps-constraints
Equations
con_obj(k) constrained objective functions
augm_obj augmented objective function to avoid weakly efficient solutions
allobj all the objective functions in one expression;
con_obj(km1).. z(km1) - dir(km1)*sl(km1) =e= rhs(km1);
* We optimize the first objective function and put the others as constraints
* the second term is for avoiding weakly efficient points
* objfun=max z1 + 0.001*(s1/r1+0.1 s2/r2+ 0.01*s3/r3+...)
augm_obj..
* sum(k1,dir(k1)*z(k1))+1.0e-3*sum(km1,power(10,-(numk(km1)-1))*sl(km1)/(maxobj(km1)-minobj(km1))) =e= a_objval;
* sum(k1,dir(k1)*z(k1))+1.0e-3*sum(km1$(maxobj(km1)-minobj(km1)),power(1000,-(numk(km1)-1))*sl(km1)/(maxobj(km1)-minobj(km1))) =e= a_objval;
sum(k1,dir(k1)*z(k1))+1.0e-3*sum(km1,power(1000,-(numk(km1)-1))*sl(km1)/(maxobj(km1)-minobj(km1))) =e= a_objval;
allobj.. sum(kk, dir(kk)*z(kk)) =e= obj;
Model mod_payoff / example, allobj / ;
Model mod_epsmethod / example, con_obj, augm_obj / ;
Parameter
payoff(k,k) payoff tables entries;
Alias(k,kp);
option optcr=0.0;
option limrow=0, limcol=0, solprint=off ;
$offlisting;
$offsymxref;
$offsymlist;
$offuelxref;
$offuellist;
*file cplexopt /cplex.opt/;
*put cplexopt;
*put 'threads 4'/;
*put 'parallelmode 1'/;
*putclose cplexopt;
*mod_epsmethod.optfile=1;
*option optca=0.;
*mod_payoff.optfile=1;
*mod_epsmethod.optfile=1;
* Generate payoff table applying lexicographic optimization
loop(kp,
kk(kp)=yes;
repeat
* solve mod_payoff using mip maximizing obj;
solve mod_payoff using mip maximizing obj;
payoff(kp,kk) = z.l(kk);
z.fx(kk) = z.l(kk);
*// freeze the value of the last objective optimized
kk(k++1) = kk(k);
*cycle through the objective functions
until kk(kp); kk(kp) = no;
* release the fixed values of the objective functions for the new iteration
z.up(k) = inf; z.lo(k) =-inf;
);
if (mod_payoff.modelstat<>1 and mod_payoff.modelstat<>8, abort 'no optimal solution for mod_payoff');
File fx /C:\Users\Åeyda\Desktop\Augmecon2\50nokta\payofftable.out / ;
PUT fx ' PAYOFF TABLE'/ ;
loop (kp,
loop(k, put payoff(kp,k):12:2);
put /;
);
put fx /;
*display payoff;
minobj(k)=smin(kp,payoff(kp,k));
*minobj(k)=0;
maxobj(k)=smax(kp,payoff(kp,k));
**$ontext
*$set fname h.%scrext.dat%
*gridpoints=max integer of km1 = 4149 or 1093
*$if not set gridpoints $set gridpoints 822
$if not set gridpoints $set gridpoints 10
Set g grid points /g0*g%gridpoints%/
grid(k,g) grid
Parameter
gridrhs(k,g) rhs of eps-constraint at grid point
maxg(k) maximum point in grid for objective
posg(k) grid position of objective
firstOffMax, lastZero some counters
* numk(k) ordinal value of k starting with 1
numg(g) ordinal value of g starting with 0
step(k) step of grid points in objective functions
jump(k) jumps in the grid points' traversing
;
lastZero=1; loop(km1, numk(km1)=lastZero; lastZero=lastZero+1); numg(g) = ord(g)-1;
grid(km1,g) = yes;
*Here we could define different grid intervals for different objectives
*aşağıdaki satırda $'lı koşul ekledim.
maxg(km1)$(smax(grid(km1,g), numg(g))) = smax(grid(km1,g), numg(g));
*aşağıdaki satırda $'lı koşul ekledim.
step(km1)$(maxg(km1))=(maxobj(km1)- minobj(km1))/maxg(km1);
gridrhs(grid(km1,g))$(dir(km1)=-1) = maxobj(km1) - numg(g)/maxg(km1)*(maxobj(km1)- minobj(km1));
gridrhs(grid(km1,g))$(dir(km1)=1) = minobj(km1) + numg(g)/maxg(km1)*(maxobj(km1)- minobj(km1));
*display gridrhs;
PUT fx ' Grid points'/ ;
loop (g,
loop(km1, put gridrhs(km1,g):12:2);
put /;
);
put fx /;
put fx 'Efficient solutions'/;
* Walk the grid points and take shortcuts if the model becomes infeasible
posg(km1) = 0;
iter=0;
infeas=0;
start=jnow;
repeat
rhs(km1) = sum(grid(km1,g)$(numg(g)=posg(km1)), gridrhs(km1,g));
* solve mod_epsmethod maximizing a_objval using mip;
solve mod_epsmethod maximizing a_objval using mip;
iter=iter+1;
if (mod_epsmethod.modelstat<>1 and mod_epsmethod.modelstat<>8,
*not optimal is in this case infeasible
infeas=infeas+1;
put fx iter:5:0, ' infeasible'/;
lastZero = 0; loop(km1$(posg(km1)>0 and lastZero=0), lastZero=numk(km1));
posg(km1)$(numk(km1)<=lastZero) = maxg(km1);
*skip all solves for more demanding values of rhs(km1)
else
put fx iter:5:0;
loop(k, put fx z.l(k):12:2);
put fx ' *** ';
*// put /;
*desicion variables section
loop(J, put fx X.l(J):1:0);
*end desicion variables section
loop(km1, put fx sl.l(km1):12:2);
put fx ' *** ';
*// put /;
jump(km1)=1;
* find the first off max (obj function that hasn't reach the final grid point).
* If this obj.fun is k then assign jump for the 1..k-th objective functions
firstOffMax = 0;
loop(km1$(posg(km1)<maxg(km1) and firstOffMax=0), firstOffMax=numk(km1));
jump(km1)$(numk(km1)<=firstOffMax)=1+floor(sl.L(km1)/step(km1));
* put ' lastzero= ', lastzero:3:0 ;
loop(km1, put fx jump(km1):5:0) ;
loop(km1$(jump(km1)>1),put ' jump');
put /;
);
* Proceed forward in the grid
firstOffMax = 0;
loop(km1$(posg(km1)<maxg(km1) and firstOffMax=0), posg(km1)=min((posg(km1)+jump(km1)),maxg(km1)); firstOffMax=numk(km1));
posg(km1)$(numk(km1)<firstOffMax) = 0;
*until sum(km1$(posg(km1)=maxg(km1)),1)= card(km1) and firstOffMax=0;
until sum(km1$(posg(km1)=maxg(km1)),1)= card(km1) and firstOffMax=0;
finish=jnow;
elapsed_time=(finish-start)*86400;
put /;
put 'Infeasibilities = ', infeas:5:0 /;
put 'Elapsed time: ',elapsed_time:10:2, ' seconds' / ;
*$offtext
putclose fx;
*close the point file
display x.l;
display w.l;
**$offtext