Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Juan-Carlos-Cruz/robotaxi-zoox/llms.txt

Use this file to discover all available pages before exploring further.

ejecucion.py provides two functions that sit between the UI and the raw search implementations. ejecutar_algoritmo is a unified dispatcher that looks up a string algorithm name in ALGORITHM_CONFIG, selects the correct search module (busqueda_informada or busqueda_no_informada), and fires it against a Grid. imprimir_resultado is a companion reporter that formats and prints every metric from a result dict to the console, including optional fields such as search time and heuristic value.

Import

from application.ejecucion import ejecutar_algoritmo, imprimir_resultado

ejecutar_algoritmo

ejecutar_algoritmo(nombre, grid) -> dict | None
Looks up nombre in ALGORITHM_CONFIG, resolves the search type and mode, then delegates to the appropriate search function. For informed algorithms it passes grid.inicio, grid.destino, and grid.pasajeros directly. For uninformed algorithms it wraps grid.inicio in a Node and converts grid.pasajeros to a frozenset before calling busqueda_no_informada.
nombre
str
required
The algorithm key as registered in ALGORITHM_CONFIG. Must be one of 'a_estrella', 'avara', 'amplitud', 'costo', or 'profundidad'. Raises KeyError if the key is not found.
grid
Grid
required
A fully constructed map object with grid.inicio, grid.destino, and grid.pasajeros set. Produced by Grid(leer_mapa()).

ALGORITHM_CONFIG mapping

The dispatcher resolves each human-readable name to a (search_type, mode) tuple defined in application/config.py:
nombre keySearch typeMode passed to search function
'a_estrella''informada''a_estrella'
'avara''informada''avara'
'amplitud''no_informada''bfs'
'costo''no_informada''ucs'
'profundidad''no_informada''dfs'

Return value

Returns the dict produced by the underlying search function, or None if no solution exists. See Uninformed Search and Informed Search for full result key documentation.
Raises KeyError if nombre is not a key in ALGORITHM_CONFIG. Validate the name before calling this function if it comes from user input.

imprimir_resultado

imprimir_resultado(resultado) -> None
Prints a formatted summary of a search result to standard output. Always prints costo, pasos, camino, nodos_expandidos, and profundidad. Conditionally appends tiempo_busqueda_ms and heuristica if those keys are present in the result dict.
resultado
Mapping[str, object]
required
A result dict as returned by ejecutar_algoritmo. Must contain costo, camino, nodos_expandidos, and profundidad. May optionally contain tiempo_busqueda_ms (or the legacy key tiempo) and heuristica.
imprimir_resultado checks for both 'tiempo_busqueda_ms' and the legacy key 'tiempo' when printing search time, so results produced by older code paths are handled gracefully.

Example console output

✅ Solución encontrada. Costo: 14
Pasos: 15
camino: [(2, 0), (3, 0), ...]
nodos expandidos: 87
profundidad: 14
tiempo de búsqueda: 3.45 ms
When heuristica is present (informed search results), an additional line is appended:
heuristica: 0

Full example

import time
from mundo import Grid, leer_mapa
from application.ejecucion import ejecutar_algoritmo, imprimir_resultado

matriz = leer_mapa()
grid = Grid(matriz)

t0 = time.perf_counter()
resultado = ejecutar_algoritmo('a_estrella', grid)
t1 = time.perf_counter()

if resultado:
    resultado['tiempo_busqueda_ms'] = round((t1 - t0) * 1000, 2)
    imprimir_resultado(resultado)
Attach tiempo_busqueda_ms to the result dict before passing it to imprimir_resultado to get the search duration printed automatically — no changes to either function are needed.

Build docs developers (and LLMs) love