-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
64 lines (57 loc) · 2 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
from Entrega import Entrega
import sys
import time
def menu():
print("-----------------------------------")
print("1) BFS")
print("2) Busqueda de Costo Uniforme")
print("3) A*")
print("4) Salir")
opcion = int(input("Ingrese la opcion a realizar: "))
print("-----------------------------------")
return opcion
def leerArchivoProblema(nombreArchivo):
with open(nombreArchivo, "r") as archivo:
datos = archivo.readlines()
return datos
def crearEntrega():
datosArchivo = leerArchivoProblema(sys.argv[2])
lugaresEntregas = []
for indice, dato in enumerate(datosArchivo):
if indice == 0:
ubicacionInicial = dato.strip()
elif indice == 1:
costoMaximo = float(dato.strip())
else:
lugaresEntregas.append(dato.strip())
return Entrega(ubicacionInicial, lugaresEntregas, costoMaximo)
def main():
print("Mini proyecto Sistemas Inteligentes")
print("-----------------------------------")
#cargar Archivos
servicioEntregas = crearEntrega()
servicioEntregas.cargarMapa(sys.argv[1])
print("Se cargo el mapa correctamente.")
opcion = 0
while opcion != 4:
opcion = menu()
if opcion == 1:
timeInicio = time.time()
servicioEntregas.BFS()
timeFinal = time.time()
timeT = timeFinal - timeInicio
print("A la busqueda BFS le tomo %s segundos" % (timeT))
if opcion == 2:
timeInicio = time.time()
servicioEntregas.uniformCostSearch()
timeFinal = time.time()
timeT = timeFinal - timeInicio
print("A la busqueda de costo uniforme le tomo %s segundos" % (timeT))
elif opcion == 3:
timeInicio = time.time()
servicioEntregas.aEstrella()
timeFinal = time.time()
timeT = timeFinal - timeInicio
print("A la busqueda A* le tomo %s segundos" % (timeT))
if __name__ == "__main__":
main()