Hi,

I wrote the code of my model but lots of error occured. I am very inexperienced with using GAMS so if you help me in codding the model I will be very glad.

My mathematical model is in the first document with name “Current Model” and my GAMS codes written below;

sets

i “store in the first sequence” /0*14/
j “store in the second sequence” /0*14/

s “stores’ intermediary sequence” /0*14/

k “vehicle in the route” /1*4/;

table d(i,j) “distance between the node i and the node j”

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

0 M M 10 15 22 6 8 12 8 26 19 31 25 22 9

1 M M 9 17 26 25 6 3 19 31 34 20 8 16 14

2 10 9 M 9 6 11 15 16 13 25 24 15 9 10 34

3 15 17 9 M 5 19 22 24 9 25 14 31 19 10 26

4 22 26 6 5 M 14 13 10 25 29 23 12 34 32 9

5 6 25 11 19 14 M 27 31 24 15 7 19 9 26 21

6 8 6 15 22 13 27 M 17 14 12 10 20 30 8 34

7 12 3 16 24 10 31 17 M 20 30 35 12 18 16 22

8 8 19 13 9 25 24 14 20 M 16 8 19 16 11 7

9 26 31 25 25 29 15 12 30 16 M 19 10 19 25 9

10 19 34 24 14 23 7 10 35 8 19 M 22 23 5 19

11 31 20 15 31 12 19 20 12 19 10 22 M M M M

12 25 8 9 19 34 9 30 18 16 29 23 M M M M

13 22 16 10 10 32 26 8 16 11 25 5 M M M M

14 9 14 34 26 9 21 34 22 7 9 19 M M M M

;

parameter CW(k) “Weight Capacity of vehicle k”

/1 15000,

2 18000,

3 25000,

4 25000/

;

parameter CV(k) “Volume Capacity of vehicle k”

/1 300,

2 400,

3 550,

4 700/

;

parameter DW(j) “Weight of Demand of node j”

/2 1800,

3 2800,

4 5000,

5 7000,

6 2900,

7 4300,

8 10000,

9 9600,

10 6400/

;

parameter DV(j) “Volume of Demand of node j”

/2 80,

3 55,

4 65,

5 100,

6 85,

7 135,

8 75

9 95,

10 105/

;

scalars

M “A large number” /50000/,

N “total number of store” /9/;

free variable totaldistance “total distance”;

binary variable

x(i,j,k) “whether vehicle k travel between node i and node j”;

equations

obj “min totaldistance”

c1(i) “Every vehicle of WMH must arrive at WMH”

c2(i) “Every store i must be serviced by the vehicle of WMH”

c3(k) “At least one vehicle of WMH must go from WMH to the store(s) i”

c4(i,j) “No vehicles’ routes end up with any stores”

c5(i,j,k) “Vehicles of WMH which will return to centre warehouse and the vehicles of CW must go to the store(s) j to take away the goods”

c6(i,j) “WMH Vehicles which went from the CW to the store(s) j, must go homes from the last store of the route (i,j)”

c7(i,j) “CW vehicle which went from the CW to the store(s) j, must go back to CW from the last store of the route (i,j)”

c8(i,j) “Demand as weight must not exceed the weight capacity of vehicle k”

c9(i,j) “Demand as volume must not exceed the volume capacity of vehicle k”

c10(i,j,k) “Subtour Elimination (Loop Constraint)”

;

obj…totaldistance=e=sum((i,j,k),d(i,j)*x(i,j,k));

c1(i)…sum(((ord(i)=11)),x(i,0,k))=e=4;

c2(i)…sum(((ord(i)=2)),x(0,i,k))=e=1;

c3(k)…sum((ord(k)=2)),x(i,s,k))-sum(((ord(j)=2)),x(s,j,k))=e=0;

c5(i,j,k)…sum(((ord(i)=2),(ord(k)=2),(ord(k)=4)),x(1,j,k))=e=0;

c6(i,j)…sum(((ord(i)=2)),x(1,i,k))-sum(((ord(j)=2),(ord(i)>=11)),x(j,i,k))=e=0;

c7(i,j)…sum(((ord(i)=2)),x(1,i,k))-sum(((ord(j)=2),(ord(k)=4)),x(j,1,k))=e=0;

c8(i,j)…sum(((ord(i)=2),((ord(j)=2)),DW(j)*x(i,j,k))=l=CW(k);

c9(i,j)…sum(((ord(i)=2),((ord(j)=2)),DV(j)*x(i,j,k))=l=CV(k);

c10(i,j,k)…sum((i,j,k),x(i,j,k))=l=(N-1);

model sunum_model /all/;

## solve sunum_model using MIP minimizing totaldistance;

\

Current Model.docx (33.8 KB)