Optimizing bus assignement to routes

Problems with modeling
Post Reply
Essouaied Aziz
User
User
Posts: 13
Joined: 4 years ago

Optimizing bus assignement to routes

Post by Essouaied Aziz »

Hello GAMS users;

I'm kind of new to GAMS, so I hope I could get some help with this problem.
I'm workin on the problem of bus assignement to routes, this is an extension to the "Transport" problem code in GAMS library, yet it is more complicated.
I want to minimize the number of buses to assign to each route and in each work season, depending on the passenger demand for each route and each season.
The result I want to have from GAMS is a Table showing the number of buses to assign for each route, by work season, in a way that the total number of buses by season doesn't exceed the total number of available buses (which is a fixed constant), but at the same time, the assigned buses should cover the demand and shouldn't leave any passenger without transporting him.

I have formulated the mathematical problem, and I've tried to write a GAMS code, but it seems that I'm missing something with my code.

I would be grateful if I could get some help, it will be nice to get a full on code that could help me solve the problem or to get a correction of my code.

With thanks!
Attachments
Code SNTRI.gms
The GAMS code that I've tried
(14.16 KiB) Downloaded 163 times
Model.docx
A Word File of the Model
(16.17 KiB) Downloaded 170 times
Essouaied Aziz
User
User
Posts: 13
Joined: 4 years ago

Re: Optimizing bus assignement to routes

Post by Essouaied Aziz »

Hi again GAMS users;
I've spent some time correcting and perfecting the model, yet I still get some errors. Basically I get Errors 149, 2, 243.
I've tried to deal with those but I've got lost.

Here is the current code I'm working on (I attach it to this post aswell):
Sets
i /100
101
102
103
104
105
106
107
108
109
110
113
114
115
116
117
118
119
122
123
124
125
128
129
130
131
132
133
134
135
136
138
139
141
142
143
145
146
149
151
152
153
154
155
157
162
164
167
168
169
170
173
174
175
176
178
179
182
183
189
192
194
206
209
219
300
306
321
501
502
503
504
506
507
508
509
510
512
517
518/
j /1*4/
t /1*4/;

Alias (i,ii);

Parameters
D(i,j) Distribution de la Demande sur par Ligne i et Période j
FV(i,j) Variable binaire indiquant si la route i est desservie pendant la saison j
P(i) Variable binaire indiquant si la route i est active
Cap(t) Capacité des bus par type
Min(j) Minimum de bus requis par saison;

Scalar bigM;
bigM = 1000;

Table D(i,j) Distribution de la Demande pour la Ligne i et la Période j
1 2 3 4
100 13921 13496 33134 22629
101 13017 12620 30983 21160
102 16842 16328 40087 27378
103 3209 3111 7639 5217
104 9931 9628 23637 16143
105 12302 11927 29281 19998
106 395 382 939 641
107 11676 11320 27791 18980
108 14341 13903 34133 23311
109 90 87 213 145
110 2845 2758 6772 4625
113 16537 16032 39361 26882
114 12717 12329 30269 20673
115 12237 11863 29126 19892
116 370 359 881 602
117 122 118 291 199
118 8153 7905 19406 13254
119 255 247 607 414
122 13278 12873 31605 21585
123 14297 13861 34030 23241
124 1620 1571 3856 2633
125 37 36 88 60
128 62 60 148 101
129 67 65 158 108
130 1 1 1 1
131 8890 8619 21161 14452
132 3352 3250 7979 5449
133 478 463 1137 777
134 37 36 89 61
135 10196 9885 24269 16574
136 42 40 99 68
138 4515 4377 10745 7339
139 14792 14341 35207 24045
141 12123 11753 28854 19706
142 1993 1932 4744 3240
143 13278 12873 31603 21584
145 6258 6068 14896 10174
146 1004 973 2389 1632
149 15059 14599 35842 24479
151 1529 1482 3639 2485
152 8573 8311 20405 13936
153 34 33 80 55
154 10 9 23 16
155 6 5 13 9
157 10 9 23 16
162 12927 12533 30769 21014
164 11696 11339 27837 19012
167 66 64 157 107
168 59 57 139 95
169 1083 1050 2577 1760
170 1302 1263 3100 2117
173 4047 3923 9632 6578
174 1332 1291 3170 2165
175 71 69 170 116
176 253 246 603 412
178 80 78 191 130
179 16679 16170 39699 27113
182 85 82 202 138
183 13012 12615 30971 21152
189 13329 12923 31726 21668
192 2134 2069 5080 3469
194 12774 12384 30404 20765
206 9876 9575 23507 16054
209 13941 13516 33182 22662
219 67 65 159 109
300 9223 8942 21952 14992
306 1 1 2 1
321 20 20 49 33
501 12934 12539 30785 21025
502 13643 13227 32474 22178
503 11162 10821 26566 18144
504 10998 10663 26178 17879
506 12878 12485 30652 20934
507 5699 5525 13565 9264
508 11939 11575 28417 19408
509 11285 10940 26859 18344
510 670 650 1595 1090
512 16055 15565 38213 26098
517 13875 13451 33024 22554
518 12618 12233 30032 20511;

Table FV(i,j) Facteur du voyage de la Ligne i et la Période j
1 2 3 4
100 303.429 313.714 627.429 473.143
101 217.846 225.231 450.462 339.692
102 166.588 172.235 344.471 259.765
103 212.400 219.600 439.200 331.200
104 166.588 172.235 344.471 259.765
105 354.000 366.000 732.000 552.000
106 298.105 308.211 616.421 464.842
107 274.065 283.355 566.710 427.355
108 314.667 325.333 650.667 490.667
109 472.000 488.000 976.000 736.000
110 354.000 366.000 732.000 552.000
113 314.667 325.333 650.667 490.667
114 314.667 325.333 650.667 490.667
115 386.182 399.273 798.545 602.182
116 283.200 292.800 585.600 441.600
117 177.000 183.000 366.000 276.000
118 404.571 418.286 836.571 630.857
119 472.000 488.000 976.000 736.000
122 369.391 381.913 763.826 576.000
123 346.776 358.531 717.061 540.735
124 404.571 418.286 836.571 630.857
125 435.692 450.462 900.923 679.385
128 514.909 532.364 1064.727 802.909
129 472.000 488.000 976.000 736.000
130 472.000 488.000 976.000 736.000
131 514.909 532.364 1064.727 802.909
132 531.000 549.000 1098.000 828.000
133 404.571 418.286 836.571 630.857
134 257.455 266.182 532.364 401.455
135 283.200 292.800 585.600 441.600
136 283.200 292.800 585.600 441.600
138 472.000 488.000 976.000 736.000
139 472.000 488.000 976.000 736.000
141 314.667 325.333 650.667 490.667
142 177.000 183.000 366.000 276.000
143 202.286 209.143 418.286 315.429
145 377.600 390.400 780.800 588.800
146 173.388 179.265 358.531 270.367
149 195.310 201.931 403.862 304.552
151 404.571 418.286 836.571 630.857
152 435.692 450.462 900.923 679.385
153 435.692 450.462 900.923 679.385
154 354.000 366.000 732.000 552.000
155 566.400 585.600 1171.200 883.200
157 377.600 390.400 780.800 588.800
162 188.800 195.200 390.400 294.400
164 339.840 351.360 702.720 529.920
167 283.200 292.800 585.600 441.600
168 283.200 292.800 585.600 441.600
169 354.000 366.000 732.000 552.000
170 472.000 488.000 976.000 736.000
173 472.000 488.000 976.000 736.000
174 369.391 381.913 763.826 576.000
175 404.571 418.286 836.571 630.857
176 354.000 366.000 732.000 552.000
178 150.372 155.469 310.938 234.478
179 128.727 133.091 266.182 200.727
182 314.667 325.333 650.667 490.667
183 202.286 209.143 418.286 315.429
189 161.829 167.314 334.629 252.343
192 314.667 325.333 650.667 490.667
194 149.053 154.105 308.211 232.421
206 435.692 450.462 900.923 679.385
209 182.710 188.903 377.806 284.903
219 236.000 244.000 488.000 368.000
300 5142909 532.364 1064.727 802.909
306 514.909 532.364 1064.727 802.909
321 514.909 532.364 1064.727 802.909
501 190.921 197.393 394.787 297.708
502 141.600 146.400 292.800 220.800
503 149.053 154.105 308.211 232.421
504 160.302 165.736 331.472 249.962
506 166.588 172.235 344.471 259.765
507 171.636 177.455 354.909 267.636
508 236.000 244.000 488.000 368.000
509 209.778 216.889 433.778 327.111
510 188.800 195.200 390.400 294.400
512 178.863 184.926 369.853 278.905
517 128.727 133.091 266.182 200.727
518 160.302 165.736 331.472 249.962;

Parameters Min(j) Minimum de Voyages requis pour la Période j
/1 59
2 61
3 122
4 92/

Parameter Cap(t)
/1 55
2 53
3 51
4 49/

Parameter P(i) Proportion de Voyage pour la Ligne i (de toutes les Lignes)
/100 0.0258605
101 0.0241818
102 0.0312868
103 0.0059617
104 0.0184483
105 0.0228528
106 0.0007329
107 0.0216898
108 0.0266398
109 0.0001663
110 0.0052855
113 0.0307200
114 0.0236242
115 0.0227318
116 0.0006876
117 0.0002270
118 0.0151461
119 0.0004734
122 0.0246665
123 0.0265595
124 0.0030095
125 0.0000687
128 0.0001151
129 0.0001236
130 0.0000012
131 0.0165154
132 0.0062276
133 0.0008877
134 0.0000695
135 0.0189410
136 0.0000774
138 0.0083864
139 0.0274785
141 0.0225200
142 0.0037029
143 0.0246654
145 0.0116261
146 0.0018649
149 0.0279738
151 0.0028403
152 0.0159257
153 0.0000625
154 0.0000178
155 0.0000105
157 0.0000178
162 0.0240140
164 0.0217263
167 0.0001227
168 0.0001087
169 0.0020110
170 0.0024192
173 0.0075177
174 0.0024738
175 0.0001324
176 0.0004707
178 0.0001490
179 0.0309838
182 0.0001578
183 0.0241724
189 0.0247612
192 0.0039647
194 0.0237297
206 0.0183466
209 0.0258976
219 0.0001242
300 0.0171331
306 0.0000015
321 0.0000380
501 0.0240266
502 0.0253448
503 0.0207343
504 0.0204313
506 0.0239232
507 0.0105870
508 0.0221790
509 0.0209631
510 0.0012451
512 0.0298240
517 0.0257746
518 0.0234393/

Variables
W(i,j) Nombre de bus de type W assignés à la route i pendant la saison j
X(i,j) Nombre de bus de type X assignés à la route i pendant la saison j
Y(i,j) Nombre de bus de type Y assignés à la route i pendant la saison j
Z(i,j) Nombre de bus de type Z assignés à la route i pendant la saison j;

Positive Variable W, X, Y, Z;

Equations
DemandConstraint(i,j)
CapacityConstraint(t,i,j)
FleetUtilizationConstraint
FleetAvailabilityConstraint(t,i,j)
RouteActivationConstraint(i);

DemandConstraint(i,j).. sum(t, Cap(t)*(ord(t)-51)*(ord(t)-53)*(ord(t)-55)*(ord(t)-49)) =g= D(i,j);

CapacityConstraint(t,i,j).. sum(ii, W(i,j))$((ord(t)-51)*FV(i,j)) =l= Cap(t)*sum(ii, FV(i,j));

FleetUtilizationConstraint.. sum((i,j), W(i,j) + X(i,j) + Y(i,j) + Z(i,j)) =g= 80*sum(j, Min(j));

FleetAvailabilityConstraint(t,i,j).. W(i,j) =l= Cap(t)*sum(ii, FV(i,j));

RouteActivationConstraint(i).. sum(t, FV(i,j)) =g= 1;

Model transport /all/;
Option solver = CPLEX;
Solve transport using LP minimizing sum((i, j), W(i,j) + X(i,j) + Y(i,j) + Z(i,j));

Display W, X, Y, Z;

I would love to correct my code in a way it gives my a table which shows how many buses to assign to each route by the route number and the season.

Any help please? With thanks!
Attachments
Untitled_6.gms
The GAMS code
(13.58 KiB) Downloaded 104 times
Post Reply