-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
165 lines (131 loc) · 4.36 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
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
import auxiliary.input_functions as inp
from auxiliary.presentation import clear_screen, cover
from auxiliary.process import Process, create_process
import solve.enumeration as enumeration
import solve.linear_prog as linear_prog
import solve.improvement as improvement
import solve.approximations as approximations
def menu(process):
global method_choice
method_options = {
1: "Enumeración Exhaustiva",
2: "Programación Lineal",
3: "Mejoramiento de Políticas",
4: "Mejoramiento de Políticas con Descuento",
5: "Aproximaciones Sucesivas",
0: "Salir"
}
while True:
clear_screen()
print("Métodos disponibles:\n")
for opcion in method_options.keys():
print(f"{opcion} --- {method_options[opcion]}")
while True:
method_choice = inp.number("\n¿Qué método desea utilizar? ", min_value=0, max_value=5)
break
if method_choice == 1:
clear_screen()
enumeration.main(process)
continue
elif method_choice == 2:
clear_screen()
linear_prog.main(process)
continue
elif method_choice == 3:
clear_screen()
improvement.main(process, False)
continue
elif method_choice == 4:
clear_screen()
improvement.main(process, True)
continue
elif method_choice == 5:
clear_screen()
approximations.main(process)
continue
elif method_choice == 0:
clear_screen()
break
if __name__ == "__main__":
# Ejemplo de las máquinas con deterioro visto durante el curso
ejemplo_maquinas = Process(
states=[0, 1, 2, 3],
decisions=[1, 2, 3],
decision_applicability=[None,
[True, True, True, False],
[False, False, True, False],
[False, True, True, True]],
costs=[[None, 0.0, None, None],
[None, 1000.0, None, 6000.0],
[None, 3000.0, 4000.0, 6000.0],
[None, None, None, 6000.0]],
transition=[None,
[[0.0, 0.875, 0.0625, 0.0625],
[0.0, 0.75, 0.125, 0.125],
[0.0, 0.0, 0.5, 0.5],
None],
[None,
None,
[0.0, 1.0, 0.0, 0.0],
None],
[None,
[1.0, 0.0, 0.0, 0.0],
[1.0, 0.0, 0.0, 0.0],
[1.0, 0.0, 0.0, 0.0]]]
)
# Ejemplo de Drake y Josh
ejemplo_dj = Process(
states=[0, 1],
decisions=[1, 2],
decision_applicability=[None,
[True, True],
[True, True]],
costs=[[None, 0.0, 0.0],
[None, 1200.0, 1200.0]],
transition=[None,
[[0.6, 0.4],
[0.6, 0.4]],
[[0.4, 0.6],
[0.5, 0.5]]
]
)
# Ejemplo de Poker del ejercicio de clase del 17 de abril
ejemplo_poker = Process(
states=[0, 1],
decisions=[1, 2],
decision_applicability=[None,
[True, True],
[True, True]],
costs=[[None, 75.0, 14.0],
[None, 0.0, 14.0]],
transition=[None,
[[7/8, 1/8],
[7/8, 1/8]],
[[1/8, 7/8],
[1/8, 7/8]]
]
)
# Ejemplo de Poker del segundo parcial
ejemplo_poker_examen = Process(
states=[0, 1],
decisions=[1, 2],
decision_applicability=[None,
[True, True],
[True, True]],
costs=[[None, 45.0, 23.0],
[None, 0.0, 23.0]],
transition=[None,
[[6/8, 2/8],
[6/8, 2/8]],
[[3/8, 5/8],
[3/8, 5/8]]
]
)
cover()
process = create_process()
# process = ejemplo_maquinas
# process = ejemplo_poker_examen
clear_screen()
print(process)
input("Presione enter para continuar al menú de métodos.")
menu(process)