-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
63 lines (55 loc) · 1.88 KB
/
main.py
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
from model import modelo
# Establecer función objetivo
with open("resultados.txt", "w", encoding="utf8") as file:
file.write("|{0:10}|{1:10}|{2:5}|{3:5}|\n".format("Valor Obj", "Time", "Sol Count", "Gap"))
print("|{0:10}|{1:10}|{2:5}|{3:5}|".format("Valor Obj", "Time", "Sol Count", "Gap", "BestBound"))
for i in [0, 5]:
m = modelo(i)
m.setParam("TimeLImit", 10800)
m.optimize()
print("--------------------------------Partidos a optimizar " + str(i + 1) +"-------------------------------")
with open("resultados.txt", "a", encoding="utf8") as file:
file.write("|{0:10}|{1:10}|{2:9}|{3:5}|\n".format(m.objVal, round(m.Runtime, 2), m.solCount, m.MIPGap))
print("----------------------------------------------------------------")
"""
m = modelo(0)
m.optimize()
print("--------------------------------Partidos a optimizar " + str(15) +"-------------------------------")
with open("resultados.txt", "w", encoding="utf8") as file:
file.write("|{0:10}|{1:10}|{2:9|{3:5}|".format(m.objVal, round(m.Runtime, 2), m.solCount, m.MIPGap))
print("----------------------------------------------------------------")
"""
#m.computeIIS()
#m.write("model.ilp")
# m.printAttr("X")
"""
m.printQuality()
print()
"""
# Imprimir los valores de las variables para la solución óptima
variable_optima = []
for v in m.getVars():
if "programacion" in v.varName:
variable_optima.append(v)
utiles = []
for i in variable_optima:
if i.X == 1:
utiles.append(i)
variable_optima = []
for v in m.getVars():
if "Atractivo Ascenso" in v.varName:
variable_optima.append(v)
for i in variable_optima:
print(i)
puntos = []
for v in m.getVars():
if "puntos" in v.varName and v.X == 1:
puntos.append(v)
for i in puntos:
print(i)
puntos = []
for v in m.getVars():
if "nueva" in v.varName and v.X == 1:
puntos.append(v)
for i in puntos:
print(i)