Endogenous error

Problems with modeling
Post Reply
saeideh1992
User
User
Posts: 1
Joined: 10 months ago

Endogenous error

Post by saeideh1992 »

Hello,
I am a beginner in GAMS and I codded a model but have this error: endogenous $-control operations not allowed
can anyone help me with this?
I know that the error is related to $ used, but I have to code the attached constraints in co1 to co4:
Image
Thanks

Code: Select all

set i vessel numbers /1*3/;
Alias (i,j);
set t time slot /1*72/;
set q quay cranes /1*8/ ;


parameters
         a(i) expected arrival time /1 3, 2 11, 3 35/
         d(i) due time /1 32, 2 72, 3 52/
         l(i) length of vessel /1 32,2 30,3 29/
         NC(i) number of containers for handling /1 5181,2 10923,3 2469/
         b(i) best berthing position /1 2,2 53,3 75/
         qmax(i) maximum required QCs /1 6,2 6,3 5/
         qmin(i) minimum required QCs /1 2,2 3,3 3/
         c1(i) cost of non-optimal berthing /1 13.92,2 13.05,3 12.61/
         c2(i) cost of departure delay /1 2252.61,2 4749.14,3 1073.48/;


scalars
         c3 cost of QC handling operation /200/
         QC total QC numbers /10/
         Lv total length of quay line /1160/
         N total vessel numbers /5/
         Tp planning horizon /84/
         M sufficient big number /10000/
         MPH movement per hour for QCs /30/;

variables
         Z
         integer variable x(i)  berthing location at beginning point
         integer variable Be(i)  berthing location at end point
         integer variable y(i)  starting berth time
         integer variable e(i)  finishing berth time
         integer variable Rc(i)   number of QCs allocated to vessels in times
         binary variable Zx(i,j)   berth location of vessel i before j
         binary variable Zy(i,j)   berth time of vessel i before j
         binary variable r(i,t)  at least one QC assigned to vessel i at time t
         binary variable rq(i,t,q) q QC assigned to vessel i at time t;


Rc.lo(i) = qmin(i);
Rc.up(i) = qmax(i);

equations
         objectivefunction
         co1
         co2
         co3
         co4
         co5
         co6
         co7
         co8
         co9
         co10
         co11
         co12;

objectivefunction                ..Z=e=sum(i,c1(i)*ABS((x(i)-b(i))))+sum(i,c2(i)*(e(i)-d(i)))+sum((i,t),c3*r(i,t));
co1(i)                           ..sum((t,q)$Rc(i),ord(q)*rq(i,t,q))=e=ceil(NC(i)/MPH);
co2(t)                           ..sum((i,q)$Rc(i),ord(q)*rq(i,t,q))=l=QC;
co3(i,t)                         ..sum(q$Rc(i),ord(q)*rq(i,t,q))=g=qmin(i);
co4(i,t)                         ..sum(q$Rc(i),ord(q)*rq(i,t,q))=l=qmax(i);
co5(i,t)                         ..sum(q,rq(i,t,q))=e=r(i,t);
co6(i)                           ..sum(t,r(i,t))=e=e(i)-y(i);
co7(i,j)  $((ord(i)<>ord(j)))    ..Be(i)=l=(x(j)+M*((1-Zx(i,j))));
co8(i,j)  $((ord(i)<>ord(j)))    ..e(i)=l=(y(j)+M*(1-Zy(i,j)));
co9(i,j)  $((ord(i)<>ord(j)))    ..1=g=(Zx(i,j)+Zx(j,i)+Zy(i,j)+Zy(j,i));
co10(i)                          ..y(i)=g=a(i);
co11(i)                          ..Be(i)=l=Lv;
co12(i)                          ..e(i)=l=Tp;

model BAQCAP /all/;

solve BAQCAP using MINLP minimizing Z;
option MINLP=BONMIN;

display Z.l, x.l, Be.l, y.l, e.l, Zx.l, Zy.l, r.l, rq.l;
Attachments
image.png
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Endogenous error

Post by bussieck »

The problematic construct is sum((t,q)$Rc(i) where Rc is a variable. GAMS does not allow an endogenous parameter, i.e. a variable in a $ expression. We see this oven with binary variables. Such constructs can be rewritten with regular algebra. In your case, I don't even know what this should mean, because the $ expression (Rc(i)) does not contain any of the driving sets (t,q). I also don't find this construct anywhere in the picture with the math.

-Michael
Post Reply