-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exercise4.gms
60 lines (45 loc) · 1.21 KB
/
Exercise4.gms
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
$onText
Laboratorio 3 - MOS
Ejercicio 4
Realizado por:
Juan Andrés Romero C - 202013449
Juan Sebastián Alegría - 202011282
$offText
Sets t 'Tile set' /t1*t20/
p 'Pipes' /p1*p7/;
Parameter hasPipe(t,p) 'Establishes if said tile has or not a pipe';
hasPipe('t1', 'p1') = 1;
hasPipe('t5', 'p1') = 1;
hasPipe('t5', 'p2') = 1;
hasPipe('t9', 'p2') = 1;
hasPipe('t9', 'p3') = 1;
hasPipe('t10', 'p3') = 1;
hasPipe('t13', 'p3') = 1;
hasPipe('t14', 'p3') = 1;
hasPipe('t13', 'p4') = 1;
hasPipe('t17', 'p4') = 1;
hasPipe('t2', 'p5') = 1;
hasPipe('t3', 'p5') = 1;
hasPipe('t6', 'p5') = 1;
hasPipe('t7', 'p5') = 1;
hasPipe('t10', 'p6') = 1;
hasPipe('t11', 'p6') = 1;
hasPipe('t14', 'p6') = 1;
hasPipe('t15', 'p6') = 1;
hasPipe('t8', 'p7') = 1;
hasPipe('t12', 'p7') = 1;
hasPipe('t16', 'p7') = 1;
hasPipe('t20', 'p7') = 1;
hasPipe('t19', 'p7') = 1;
Variables x(t) 'Node selected'
z 'Target function';
Binary variable x;
Equations targetFunc 'Target Function'
minTiles(p) 'Pipe coverage constraint';
targetFunc.. z =e= sum(t, x(t));
minTiles(p).. sum(t, x(t)*hasPipe(t,p)) =g= 1;
Model exercise4 /all/;
option mip=cplex
Solve exercise4 using mip minimizing z;
Display x.l;
Display z.l;