-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExercise2.lst
277 lines (199 loc) · 8.73 KB
/
Exercise2.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
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 10/14/22 20:26:26 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 3 - MOS
Ejercicio 2
Realizado por:
Juan Andrés Romero C - 202013449
Juan Sebastián Alegría - 202011282
9
10 Sets i 'Towns' /i1*i6/
11 alias(i,j);
12
13 Parameter distance(i,j) 'Distance between towns';
14
15 distance('i1', 'i2') = 10;
16 distance('i1', 'i3') = 20;
17 distance('i1', 'i4') = 30;
18 distance('i1', 'i5') = 30;
19 distance('i1', 'i6') = 20;
20
21 distance('i2', 'i3') = 25;
22 distance('i2', 'i4') = 35;
23 distance('i2', 'i5') = 20;
24 distance('i2', 'i6') = 10;
25
26 distance('i3', 'i4') = 15;
27 distance('i3', 'i5') = 30;
28 distance('i3', 'i6') = 20;
29
30 distance('i4', 'i5') = 15;
31 distance('i4', 'i6') = 25;
32
33 distance('i5', 'i6') = 14;
34
35 * Since it's an undirected graph there are bidirectional connections
36 loop((i,j),
37 if (distance(i,j) ne 0,
38 distance(j,i) = distance(i,j)
39 );
40 );
41
42 loop((i,j),
43 if ((distance(i,j) le 15 and distance(i,j) ge 1) or (distance(j,i) le 15 and distance(j,i) ge 1),
44 distance(i,j) = 1;
45 else
46 distance(i,j) = 0;
47 );
48 );
49
50 loop((i,j),
51 if (distance(i,j) ne 0,
52 distance(j,i) = distance(i,j)
53 );
54 );
55
56 Display distance;
57
58 Variables x(i) 'Node selected'
59 z 'Target function';
60
61 Binary Variable x;
62
63 Equations targetFunc 'Target Function'
64 minZones(i) 'Fire department coverage constraint';
65
66 targetFunc.. z =e= sum(i, x(i));
67 minZones(i).. sum(j, x(j)*distance(i,j)) =g= 1;
68
69 Model exercise2 /all/;
70 option mip=cplex
71 Solve exercise2 using mip minimizing z;
72 Display x.l;
73 Display z.l;
COMPILATION TIME = 0.004 SECONDS 3 MB 40.1.0 93c2a77b DEX-DEG
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 10/14/22 20:26:26 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
E x e c u t i o n
---- 56 PARAMETER distance Distance between towns
i1 i2 i3 i4 i5 i6
i1 1.000
i2 1.000 1.000
i3 1.000
i4 1.000 1.000
i5 1.000 1.000
i6 1.000 1.000
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 10/14/22 20:26:26 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
Equation Listing SOLVE exercise2 Using MIP From line 71
---- targetFunc =E= Target Function
targetFunc.. - x(i1) - x(i2) - x(i3) - x(i4) - x(i5) - x(i6) + z =E= 0 ; (LHS = 0)
---- minZones =G= Fire department coverage constraint
minZones(i1).. x(i2) =G= 1 ; (LHS = 0, INFES = 1 ****)
minZones(i2).. x(i1) + x(i6) =G= 1 ; (LHS = 0, INFES = 1 ****)
minZones(i3).. x(i4) =G= 1 ; (LHS = 0, INFES = 1 ****)
REMAINING 3 ENTRIES SKIPPED
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 10/14/22 20:26:26 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
Column Listing SOLVE exercise2 Using MIP From line 71
---- x Node selected
x(i1)
(.LO, .L, .UP, .M = 0, 0, 1, 0)
-1 targetFunc
1 minZones(i2)
x(i2)
(.LO, .L, .UP, .M = 0, 0, 1, 0)
-1 targetFunc
1 minZones(i1)
1 minZones(i6)
x(i3)
(.LO, .L, .UP, .M = 0, 0, 1, 0)
-1 targetFunc
1 minZones(i4)
REMAINING 3 ENTRIES SKIPPED
---- z Target 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 - 10/14/22 20:26:26 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
Range Statistics SOLVE exercise2 Using MIP From line 71
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, 1.000E+00]
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 10/14/22 20:26:26 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
Model Statistics SOLVE exercise2 Using MIP From line 71
MODEL STATISTICS
BLOCKS OF EQUATIONS 2 SINGLE EQUATIONS 7
BLOCKS OF VARIABLES 2 SINGLE VARIABLES 7
NON ZERO ELEMENTS 17 DISCRETE VARIABLES 6
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 - 10/14/22 20:26:26 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
Solution Report SOLVE exercise2 Using MIP From line 71
S O L V E S U M M A R Y
MODEL exercise2 OBJECTIVE z
TYPE MIP DIRECTION MINIMIZE
SOLVER CPLEX FROM LINE 71
**** SOLVER STATUS 1 Normal Completion
**** MODEL STATUS 1 Optimal
**** OBJECTIVE VALUE 4.0000
RESOURCE USAGE, LIMIT 0.040 10000000000.000
ITERATION COUNT, LIMIT 0 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.01sec (det. 0.01 ticks)
--- Fixing integer variables and solving final LP...
--- Fixed MIP status (1): optimal.
--- Cplex Time: 0.00sec (det. 0.00 ticks)
Proven optimal solution
MIP Solution: 4.000000 (0 iterations, 0 nodes)
Final Solve: 4.000000 (0 iterations)
Best possible: 4.000000
Absolute gap: 0.000000
Relative gap: 0.000000
LOWER LEVEL UPPER MARGINAL
---- EQU targetFunc . . . 1.0000
targetFunc Target Function
---- EQU minZones Fire department coverage constraint
LOWER LEVEL UPPER MARGINAL
i1 1.0000 1.0000 +INF .
i2 1.0000 1.0000 +INF .
i3 1.0000 1.0000 +INF .
i4 1.0000 1.0000 +INF .
i5 1.0000 1.0000 +INF .
i6 1.0000 1.0000 +INF .
---- VAR x Node selected
LOWER LEVEL UPPER MARGINAL
i1 . 1.0000 1.0000 1.0000
i2 . 1.0000 1.0000 1.0000
i3 . 1.0000 1.0000 1.0000
i4 . 1.0000 1.0000 1.0000
i5 . . 1.0000 1.0000
i6 . . 1.0000 1.0000
LOWER LEVEL UPPER MARGINAL
---- VAR z -INF 4.0000 +INF .
z Target function
**** REPORT SUMMARY : 0 NONOPT
0 INFEASIBLE
0 UNBOUNDED
GAMS 40.1.0 93c2a77b Aug 1, 2022 DEX-DEG x86 64bit/Mac OS X - 10/14/22 20:26:26 Page 8
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
---- 72 VARIABLE x.L Node selected
i1 1.000, i2 1.000, i3 1.000, i4 1.000
---- 73 VARIABLE z.L = 4.000 Target function
EXECUTION TIME = 0.084 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-03/exercise2.gms
Output /Users/zejiran/hack/uniandes/MSO/laboratory-03/exercise2.lst