How lucasgabriel-cp/tcc works
Project type and purpose
• The README shows the title “TCC” ("Trem de Comer Cedo"), which appears to be a specific application (possibly a research or academic project) in which the objective is to solve complex optimization problems.
• The project is split between an “exact model” and “metaheuristics” approaches. This indicates that the system is designed to compare or integrate both an exact optimization method (using Gurobi via Python) and various heuristic/metaheuristic algorithms (implemented in C++).
File structure
• At the top level, there are two main directories: “exact_model” and “metaheuristics.”
• The “exact_model” folder contains Python files:
• gurobi_opt.py – likely orchestrating the optimization using Gurobi.
• instance_vars.py and optimization.py – possibly setting up the mathematical model.
• A configuration folder “gurobi_conf” indicating that configuration files for Gurobi are maintained separately.
• A results file (results_LKM.txt) for output from the optimization process.
• The “metaheuristics” folder includes C++ source files and a Makefile:
• Several runner files (ga_runner.cpp, hibrid_runner.cpp, ts_runner.cpp, vns_runner.cpp) denote that different metaheuristic strategies (genetic algorithm, tabu search, variable neighborhood search, and a hybrid approach) are implemented.
• Additional source files (genetic_algorithm.cpp, individuo.cpp, initial_solution.cpp, neighbor.cpp) and utility implementations (Constants.cpp, DebugTemplate.cpp, segtree.cpp, string_hash.cpp).
• A “problems” subfolder with leasing.cpp suggests example problem definitions for the metaheuristic algorithms.
• A shell script (script.sh) likely assists in running or compiling components.
• No traditional “frontend” or “database” components are present; the focus here is algorithmic optimization.
a. Main components:
• Exact Optimization Module: This encompasses the Python scripts under “exact_model” plus its Gurobi configuration. It is responsible for solving the optimization exactly using a solver.
• Metaheuristics Module: This includes the multiple C++ implementations of different heuristics (Genetic Algorithm, Hybrid, Tabu Search, VNS, etc.) provided in “metaheuristics”.
• Shared Problem Instance: There is likely a common problem definition or data file that is used as input for both the exact model and the metaheuristics. Although the file tree does not explicitly include a “data” directory, the presence of “instance_vars.py” and “problems/leasing.cpp” hints at a shared problem abstraction.
• (Optional) External Dependencies: Gurobi solver for the exact model. The C++ module might depend on standard libraries or custom libraries compiled using the Makefile.
b. Relationships and interactions:
• Both modules receive the same problem instance(s) or parameter settings.
• The exact model module calls out to the Gurobi solver (either via a direct API in gurobi_opt.py or via configuration files) to return an optimal solution.
• The metaheuristics module, which is compiled via its Makefile and executed using provided runner scripts, produces approximate solutions.
• There might be a higher-level orchestration or benchmarking mechanism (possibly executed through external scripts/sequencing) that compares the outcomes from both approaches.
c. Architectural patterns:
• Separation of Concerns: The two modules (exact vs. heuristic) are separated to allow independent development and testing.
• Modular Design: Each metaheuristic algorithm is implemented in its own runner file and helper modules, while the exact model consolidates configuration and logic in Python, showing a clean division of responsibilities.
• Integration via Common Interfaces: Both methods target the same underlying problem instance, which is abstracted to allow algorithmic comparisons (benchmarking).
d. Relevant technologies:
• Python and Gurobi: Used in the exact optimization pipeline.
• C++ (with a Makefile for build automation): Used for the metaheuristic implementations.
• Shell scripting may be used for launching or automating execution.
• The design should note that configuration files (in gurobi_conf) influence the behavior of the exact model.
• Use clear labels for every component (e.g., “Gurobi Solver”, “Python Optimization Code”, “C++ GA Module”, “C++ Tabu Search Module”).
• From “Problem Instance” to both “Exact Optimization Module” and “Metaheuristics Module.”
• From “Exact Optimization Module” to “Gurobi Solver” (denoting API/configuration flow).
• From each metaheuristic sub-component to a collective “Solution Output” or “Benchmarking Interface.”
• Rectangles for software modules.
• Configuration files and build scripts as auxiliary nodes to hint at how modules are deployed or compiled.
Detail and modular separation
• As the principal software engineer, include as many detailed components as possible: break down the metaheuristics into their individual strategies, highlight the exact model’s dependency on Gurobi, and illustrate the overall data flow from problem definition to solution output.