-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise4.lst
330 lines (240 loc) · 14.4 KB
/
exercise4.lst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 09/14/22 14:24:02 Page 1
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
C o m p i l a t i o n
Laboratorio 2 - MOS
Ejercicio 4
Realizado por:
Juan Andrés Romero C - 202013449
Juan Sebastián Alegría - 202011282
9
10 Sets i 'Graph nodes' /i1*i7/
11 coords 'Coordinate dimensions' /coordX, coordY/
12 alias(j,i);
13
14 Table positions(i,coords)
15
16 coordX coordY
17 i1 20 6
18 i2 22 1
19 i3 9 2
20 i4 3 25
21 i5 21 10
22 i6 29 2
23 i7 14 12;
24
25 Parameters distance(i,j) 'Distances between nodes'
26 graph(i,j) 'Resulting graph of connections between the node set';
27
28 loop((i,j),
29 distance(i,j) = sqrt(sqr(positions(i,'coordX')-positions(j,'coordX')) + sqr(positions(i,'coordY')-positions(j,'coordY')));
30 if ((distance(i,j) <= 20 and distance(i,j) > 0),
31 graph(i,j) = distance(i,j);
32 else
33 graph(i,j) = 999;
34 );
35 );
36
37 Scalar sourceNode /4/;
38 Scalar destinationNode /6/;
39
40 Variables x(i,j) 'Indicates if the link i-j is selected or not'
41 z 'Objective function';
42
43 Binary Variable x;
44
45 Equations
46 targetFunc 'target function'
47 sourceNodeRestriction(i) 'source node'
48 destinationNodeRestriction(j) 'destination node'
49 intermediateNodeRestriction 'intermediate node';
50
51 targetFunc.. z =e= sum((i,j), graph(i,j)*x(i,j));
52 sourceNodeRestriction(i)$(ord(i) = sourceNode).. sum((j), x(i,j)) =e= 1;
53 destinationNodeRestriction(j)$(ord(j) = destinationNode).. sum((i), x(i,j)) =e= 1;
54 intermediateNodeRestriction(i)$(ord(i) <> sourceNode and ord(i) <> destinationNode).. sum((j), x(i,j)) - sum((j), x(j,i)) =e= 0;
55
56 Model Exercise4 /all/ ;
57 option mip=cplex
58 Solve Exercise4 using mip minimizing z;
59
60 Display graph;
61 Display x.l;
62 Display z.l;
COMPILATION TIME = 0.005 SECONDS 3 MB 40.1.0 93c2a77b DEX-DEG
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 09/14/22 14:24:02 Page 2
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Equation Listing SOLVE Exercise4 Using MIP From line 58
---- targetFunc =E= target function
targetFunc.. - 999*x(i1,i1) - 5.3851648071345*x(i1,i2) - 11.7046999107196*x(i1,i3) - 999*x(i1,i4) - 4.12310562561766*x(i1,i5) - 9.8488578017961*x(i1,i6) - 8.48528137423857*x(i1,i7) - 5.3851648071345*x(i2,i1) - 999*x(i2,i2) - 13.0384048104053*x(i2,i3) - 999*x(i2,i4) - 9.05538513813742*x(i2,i5) - 7.07106781186548*x(i2,i6) - 13.6014705087354*x(i2,i7) - 11.7046999107196*x(i3,i1) - 13.0384048104053*x(i3,i2) - 999*x(i3,i3) - 999*x(i3,i4) - 14.422205101856*x(i3,i5) - 20*x(i3,i6) - 11.1803398874989*x(i3,i7) - 999*x(i4,i1) - 999*x(i4,i2) - 999*x(i4,i3) - 999*x(i4,i4) - 999*x(i4,i5) - 999*x(i4,i6) - 17.0293863659264*x(i4,i7) - 4.12310562561766*x(i5,i1) - 9.05538513813742*x(i5,i2) - 14.422205101856*x(i5,i3) - 999*x(i5,i4) - 999*x(i5,i5) - 11.3137084989848*x(i5,i6) - 7.28010988928052*x(i5,i7) - 9.8488578017961*x(i6,i1) - 7.07106781186548*x(i6,i2) - 20*x(i6,i3) - 999*x(i6,i4) - 11.3137084989848*x(i6,i5) - 999*x(i6,i6) - 18.0277563773199*x(i6,i7) - 8.48528137423857*x(i7,i1) - 13.6014705087354*x(i7,i2) - 11.1803398874989*x(i7,i3) - 17.0293863659264*x(i7,i4) - 7.28010988928052*x(i7,i5) - 18.0277563773199*x(i7,i6) - 999*x(i7,i7) + z =E= 0 ; (LHS = 0)
---- sourceNodeRestriction =E= source node
sourceNodeRestriction(i4).. x(i4,i1) + x(i4,i2) + x(i4,i3) + x(i4,i4) + x(i4,i5) + x(i4,i6) + x(i4,i7) =E= 1 ; (LHS = 0, INFES = 1 ****)
---- destinationNodeRestriction =E= destination node
destinationNodeRestriction(i6).. x(i1,i6) + x(i2,i6) + x(i3,i6) + x(i4,i6) + x(i5,i6) + x(i6,i6) + x(i7,i6) =E= 1 ; (LHS = 0, INFES = 1 ****)
---- intermediateNodeRestriction =E= intermediate node
intermediateNodeRestriction(i1).. x(i1,i2) + x(i1,i3) + x(i1,i4) + x(i1,i5) + x(i1,i6) + x(i1,i7) - x(i2,i1) - x(i3,i1) - x(i4,i1) - x(i5,i1) - x(i6,i1) - x(i7,i1) =E= 0 ; (LHS = 0)
intermediateNodeRestriction(i2).. - x(i1,i2) + x(i2,i1) + x(i2,i3) + x(i2,i4) + x(i2,i5) + x(i2,i6) + x(i2,i7) - x(i3,i2) - x(i4,i2) - x(i5,i2) - x(i6,i2) - x(i7,i2) =E= 0 ; (LHS = 0)
intermediateNodeRestriction(i3).. - x(i1,i3) - x(i2,i3) + x(i3,i1) + x(i3,i2) + x(i3,i4) + x(i3,i5) + x(i3,i6) + x(i3,i7) - x(i4,i3) - x(i5,i3) - x(i6,i3) - x(i7,i3) =E= 0 ; (LHS = 0)
REMAINING 2 ENTRIES SKIPPED
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 09/14/22 14:24:02 Page 3
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Column Listing SOLVE Exercise4 Using MIP From line 58
---- x Indicates if the link i-j is selected or not
x(i1,i1)
(.LO, .L, .UP, .M = 0, 0, 1, 0)
-999 targetFunc
x(i1,i2)
(.LO, .L, .UP, .M = 0, 0, 1, 0)
-5.3852 targetFunc
1 intermediateNodeRestriction(i1)
-1 intermediateNodeRestriction(i2)
x(i1,i3)
(.LO, .L, .UP, .M = 0, 0, 1, 0)
-11.7047 targetFunc
1 intermediateNodeRestriction(i1)
-1 intermediateNodeRestriction(i3)
REMAINING 46 ENTRIES SKIPPED
---- z Objective function
z
(.LO, .L, .UP, .M = -INF, 0, +INF, 0)
1 targetFunc
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 09/14/22 14:24:02 Page 4
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Range Statistics SOLVE Exercise4 Using MIP From line 58
RANGE STATISTICS (ABSOLUTE NON-ZERO FINITE VALUES)
RHS [min, max] : [ 1.000E+00, 1.000E+00] - Zero values observed as well
Bound [min, max] : [ 1.000E+00, 1.000E+00] - Zero values observed as well
Matrix [min, max] : [ 1.000E+00, 9.990E+02]
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 09/14/22 14:24:02 Page 5
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Model Statistics SOLVE Exercise4 Using MIP From line 58
MODEL STATISTICS
BLOCKS OF EQUATIONS 4 SINGLE EQUATIONS 8
BLOCKS OF VARIABLES 2 SINGLE VARIABLES 50
NON ZERO ELEMENTS 124 DISCRETE VARIABLES 49
GENERATION TIME = 0.012 SECONDS 4 MB 40.1.0 93c2a77b DEX-DEG
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 09/14/22 14:24:02 Page 6
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Solution Report SOLVE Exercise4 Using MIP From line 58
S O L V E S U M M A R Y
MODEL Exercise4 OBJECTIVE z
TYPE MIP DIRECTION MINIMIZE
SOLVER CPLEX FROM LINE 58
**** SOLVER STATUS 1 Normal Completion
**** MODEL STATUS 1 Optimal
**** OBJECTIVE VALUE 35.0571
RESOURCE USAGE, LIMIT 0.049 10000000000.000
ITERATION COUNT, LIMIT 5 2147483647
--- *** This solver runs with a community license. No commercial use.
--- GMO setup time: 0.00s
--- GMO memory 0.50 Mb (peak 0.50 Mb)
--- Dictionary memory 0.00 Mb
--- Cplex 22.1.0.0 link memory 0.00 Mb (peak 0.00 Mb)
--- Starting Cplex
--- MIP status (101): integer optimal solution.
--- Cplex Time: 0.02sec (det. 0.33 ticks)
--- Fixing integer variables and solving final LP...
--- Fixed MIP status (1): optimal.
--- Cplex Time: 0.00sec (det. 0.02 ticks)
Proven optimal solution
MIP Solution: 35.057143 (5 iterations, 0 nodes)
Final Solve: 35.057143 (0 iterations)
Best possible: 35.057143
Absolute gap: 0.000000
Relative gap: 0.000000
LOWER LEVEL UPPER MARGINAL
---- EQU targetFunc . . . 1.0000
targetFunc target function
---- EQU sourceNodeRestriction source node
LOWER LEVEL UPPER MARGINAL
i4 1.0000 1.0000 1.0000 .
---- EQU destinationNodeRestriction destination node
LOWER LEVEL UPPER MARGINAL
i6 1.0000 1.0000 1.0000 .
---- EQU intermediateNodeRestriction intermediate node
LOWER LEVEL UPPER MARGINAL
i1 . . . .
i2 . . . .
i3 . . . .
i5 . . . .
i7 . . . .
---- VAR x Indicates if the link i-j is selected or not
LOWER LEVEL UPPER MARGINAL
i1.i1 . . 1.0000 999.0000
i1.i2 . . 1.0000 5.3852
i1.i3 . . 1.0000 11.7047
i1.i4 . . 1.0000 999.0000
i1.i5 . . 1.0000 4.1231
i1.i6 . . 1.0000 9.8489
i1.i7 . . 1.0000 8.4853
i2.i1 . . 1.0000 5.3852
i2.i2 . . 1.0000 999.0000
i2.i3 . . 1.0000 13.0384
i2.i4 . . 1.0000 999.0000
i2.i5 . . 1.0000 9.0554
i2.i6 . . 1.0000 7.0711
i2.i7 . . 1.0000 13.6015
i3.i1 . . 1.0000 11.7047
i3.i2 . . 1.0000 13.0384
i3.i3 . . 1.0000 999.0000
i3.i4 . . 1.0000 999.0000
i3.i5 . . 1.0000 14.4222
i3.i6 . . 1.0000 20.0000
i3.i7 . . 1.0000 11.1803
i4.i1 . . 1.0000 999.0000
i4.i2 . . 1.0000 999.0000
i4.i3 . . 1.0000 999.0000
i4.i4 . . 1.0000 999.0000
i4.i5 . . 1.0000 999.0000
i4.i6 . . 1.0000 999.0000
i4.i7 . 1.0000 1.0000 17.0294
i5.i1 . . 1.0000 4.1231
i5.i2 . . 1.0000 9.0554
i5.i3 . . 1.0000 14.4222
i5.i4 . . 1.0000 999.0000
i5.i5 . . 1.0000 999.0000
i5.i6 . . 1.0000 11.3137
i5.i7 . . 1.0000 7.2801
i6.i1 . . 1.0000 9.8489
i6.i2 . . 1.0000 7.0711
i6.i3 . . 1.0000 20.0000
i6.i4 . . 1.0000 999.0000
i6.i5 . . 1.0000 11.3137
i6.i6 . . 1.0000 999.0000
i6.i7 . . 1.0000 18.0278
i7.i1 . . 1.0000 8.4853
i7.i2 . . 1.0000 13.6015
i7.i3 . . 1.0000 11.1803
i7.i4 . . 1.0000 17.0294
i7.i5 . . 1.0000 7.2801
i7.i6 . 1.0000 1.0000 18.0278
i7.i7 . . 1.0000 999.0000
LOWER LEVEL UPPER MARGINAL
---- VAR z -INF 35.0571 +INF .
z Objective function
**** REPORT SUMMARY : 0 NONOPT
0 INFEASIBLE
0 UNBOUNDED
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 09/14/22 14:24:02 Page 7
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
E x e c u t i o n
---- 60 PARAMETER graph Resulting graph of connections between the node set
i1 i2 i3 i4 i5 i6 i7
i1 999.000 5.385 11.705 999.000 4.123 9.849 8.485
i2 5.385 999.000 13.038 999.000 9.055 7.071 13.601
i3 11.705 13.038 999.000 999.000 14.422 20.000 11.180
i4 999.000 999.000 999.000 999.000 999.000 999.000 17.029
i5 4.123 9.055 14.422 999.000 999.000 11.314 7.280
i6 9.849 7.071 20.000 999.000 11.314 999.000 18.028
i7 8.485 13.601 11.180 17.029 7.280 18.028 999.000
---- 61 VARIABLE x.L Indicates if the link i-j is selected or not
i6 i7
i4 1.000
i7 1.000
---- 62 VARIABLE z.L = 35.057 Objective function
EXECUTION TIME = 0.092 SECONDS 4 MB 40.1.0 93c2a77b DEX-DEG
USER: GAMS Community License for Juan Alegria G220811|0002AO-GEN
Universidad de los Andes, CL3634
License for teaching and research at degree granting institutions
**** FILE SUMMARY
Input /Users/zejiran/hack/uniandes/MSO/laboratory-02/exercise4.gms
Output /Users/zejiran/hack/uniandes/MSO/laboratory-02/exercise4.lst