How kalinbas/cdmxmetrochallenge works
Project Overview
• Purpose: The project computes an optimal route to visit every metro station in Mexico City. It uses several heuristic and optimization methods (greedy, 2-opt, 3-opt, k-opt) packaged under the “tsp_local” module.
• Type: This is a computation/algorithm-centric tool with a command-line interface (CLI), rather than a full-stack web application.
Identifying Main Components
• Data Input: The “metro_stations.csv” file contains the list and possibly metadata of the metro stations.
• Entry Point: “index.py” is the main script to run the application—it will orchestrate the reading of data, processing, and execution of TSP algorithms.
• Graph Representation: “graph.py” likely represents or visualizes the metro map or route graph.
• Algorithm Package (“tsp_local” module): This consists of:
○ base.py – likely defines common functionality or abstract classes for TSP algorithms.
○ greedy.py – implementation of a greedy heuristic.
○ twoopt.py – 2-opt optimization algorithm.
○ threeopt.py – 3-opt algorithm.
○ kopt.py – k-opt method for further improvements.
• Dependencies/Environment: “requirements.txt” specifies the dependencies and suggests external libraries that might be used for data processing or optimization.
Relationships and Interactions
• The entry point (index.py) will initiate the flow:
○ Read “metro_stations.csv” to gather station data.
○ Possibly use “graph.py” to build a visual or logical graph structure from the data.
○ Call functions from the “tsp_local” package to compute the optimal route using one or more of the provided algorithm implementations.
• Each algorithm module in “tsp_local” is likely interconnected through common interfaces or base classes (from base.py) to allow easy switching or comparing different TSP strategies.
• Final output (likely printed to console or saved as output) is generated in index.py after processing.
Architectural Patterns/Design Principles
• Separation of Concerns: There is a clear delineation between data input (CSV file), business logic (TSP algorithms in tsp_local), and any presentation or output layer (possibly through graph.py and the CLI interface in index.py).
• Modular Design: The “tsp_local” package is divided into separate modules for each algorithm, allowing easy extensibility or replacement.
• Data Flow Pipeline: Data flows from file reading to graph building to algorithm processing, illustrating a step-by-step transformation.
Technologies and Libraries
• Python is the core language.
• Libraries listed in “requirements.txt” (although not detailed in the snippet) may include numerical or data-handling libraries such as NumPy, pandas, or plotting libraries used in graph.py.