# datweb07/ga-eho-tsp architecture

> Architecture diagram of the GitHub repository datweb07/ga-eho-tsp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/datweb07/ga-eho-tsp
- Repository: https://github.com/datweb07/ga-eho-tsp

## Overview

GA-EHO-TSP solves symmetric TSP instances with genetic and elephant-herding optimization, and presents results through a GUI, CLI, and benchmark workflow. The main flow is dataset selection/loading, validated problem and configuration, solver execution, then result visualization or export. The GUI controller runs solvers asynchronously and relays progress/results. The graph also includes shared route/objective logic and both algorithm families. Some GUI and benchmark internals are unsampled; those links are limited to references in the source index or documented README behavior.

Main entry points: [`src/ga_eho_tsp/algorithms/ga/solver.py`](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/solver.py) (GA solver), [`src/ga_eho_tsp/algorithms/eho/solver.py`](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/eho/solver.py) (EHO solver), [`src/ga_eho_tsp/gui/app.py`](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/gui/app.py) (Tk GUI), [`src/ga_eho_tsp/cli.py`](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/cli.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_gui["Tk GUI<br/>[app.py]"]
  node_controller["Run controller<br/>[controller.py]"]
  node_cli["CLI<br/>[cli.py]"]
  node_visuals["Plots and controls<br/>[plots.py]"]
  node_gui_export["GUI export<br/>[export.py]"]
end

subgraph group_data["Problem data"]
  node_matrix["Matrix loader<br/>[matrix_loader.py]"]
  node_registry["Dataset registry<br/>[registry.py]"]
  node_benchmark["Benchmark runner<br/>[benchmark.py]"]
  node_experiment_export["Benchmark export<br/>[export.py]"]
end

subgraph group_domain["Shared domain"]
  node_models["Problem and configs<br/>[models.py]"]
  node_objective["Route objective<br/>[objective.py]"]
  node_operators["Permutation operators<br/>[operators.py]"]
  node_protocols["Solver protocol<br/>[protocols.py]"]
end

subgraph group_ga["Genetic algorithm"]
  node_ga_solver["GA solver<br/>[solver.py]"]
  node_ga_init["Population initialization<br/>[initialization.py]"]
  node_ga_selection["Parent selection<br/>[selection.py]"]
  node_ga_crossover["Crossover<br/>[crossover.py]"]
  node_ga_mutation["Mutation<br/>[mutation.py]"]
  node_ga_local["2-opt search<br/>[local_search.py]"]
  node_ga_monitor["Run monitoring<br/>[monitoring.py]"]
  node_ga_survivor["Survivor selection<br/>[survivor.py]"]
end

subgraph group_eho["Elephant optimization"]
  node_eho_solver["EHO solver<br/>[solver.py]"]
  node_clans["Clan operations<br/>[clans.py]"]
  node_discrete["Discrete updates<br/>[discrete_ops.py]"]
  node_separation["Clan separation<br/>[separation.py]"]
end

node_user(("User"))

node_user -->|"configures run"| node_gui
node_user -->|"starts command"| node_cli
node_gui -->|"loads dataset"| node_matrix
node_gui -->|"starts and polls"| node_controller
node_gui -->|"renders results"| node_visuals
node_gui -->|"exports results"| node_gui_export
node_controller -->|"dispatches solver"| node_ga_solver
node_controller -->|"dispatches solver"| node_eho_solver
node_cli -->|"loads dataset"| node_matrix
node_cli -->|"runs GA"| node_ga_solver
node_cli -->|"runs EHO"| node_eho_solver
node_cli -->|"starts benchmark"| node_benchmark
node_matrix -->|"creates problem"| node_models
node_benchmark -.->|"writes reports"| node_experiment_export
node_ga_solver -->|"initializes population"| node_ga_init
node_ga_solver -->|"selects parents"| node_ga_selection
node_ga_solver -->|"creates children"| node_ga_crossover
node_ga_solver -->|"mutates children"| node_ga_mutation
node_ga_solver -->|"improves routes"| node_ga_local
node_ga_solver -->|"records progress"| node_ga_monitor
node_ga_solver -->|"chooses survivors"| node_ga_survivor
node_ga_solver -->|"uses configs and results"| node_models
node_ga_solver -->|"evaluates routes"| node_objective
node_ga_solver -->|"implements contract"| node_protocols
node_eho_solver -->|"updates clans"| node_clans
node_eho_solver -->|"updates routes"| node_discrete
node_eho_solver -->|"separates members"| node_separation
node_eho_solver -->|"uses configs and results"| node_models
node_eho_solver -->|"evaluates routes"| node_objective
node_eho_solver -->|"initializes routes"| node_operators
node_eho_solver -->|"implements contract"| node_protocols
node_models -->|"validates and scores"| node_objective
node_operators -->|"uses route type"| node_objective
node_protocols -->|"types solver inputs"| node_models

click node_gui "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/gui/app.py"
click node_controller "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/gui/controller.py"
click node_cli "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/cli.py"
click node_visuals "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/gui/plots.py"
click node_gui_export "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/gui/export.py"
click node_matrix "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/data/matrix_loader.py"
click node_registry "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/data/registry.py"
click node_benchmark "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/experiments/benchmark.py"
click node_experiment_export "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/experiments/export.py"
click node_models "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/domain/models.py"
click node_objective "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/domain/objective.py"
click node_operators "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/domain/operators.py"
click node_protocols "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/domain/protocols.py"
click node_ga_solver "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/solver.py"
click node_ga_init "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/initialization.py"
click node_ga_selection "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/selection.py"
click node_ga_crossover "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/crossover.py"
click node_ga_mutation "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/mutation.py"
click node_ga_local "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/local_search.py"
click node_ga_monitor "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/monitoring.py"
click node_ga_survivor "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/survivor.py"
click node_eho_solver "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/eho/solver.py"
click node_clans "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/eho/clans.py"
click node_discrete "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/eho/discrete_ops.py"
click node_separation "https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/eho/separation.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gui,node_controller,node_cli,node_visuals,node_gui_export,node_user toneBlue
class node_matrix,node_registry,node_benchmark,node_experiment_export toneAmber
class node_models,node_objective,node_operators,node_protocols toneMint
class node_ga_solver,node_ga_init,node_ga_selection,node_ga_crossover,node_ga_mutation,node_ga_local,node_ga_monitor,node_ga_survivor toneRose
class node_eho_solver,node_clans,node_discrete,node_separation toneIndigo
```

## Components

### User interfaces

- [Tk GUI](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/gui/app.py): `src/ga_eho_tsp/gui/app.py`
- [Run controller](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/gui/controller.py): `src/ga_eho_tsp/gui/controller.py`
- [CLI](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/cli.py): `src/ga_eho_tsp/cli.py`
- [Plots and controls](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/gui/plots.py): `src/ga_eho_tsp/gui/plots.py`
- [GUI export](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/gui/export.py): `src/ga_eho_tsp/gui/export.py`

### Problem data

- [Matrix loader](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/data/matrix_loader.py): `src/ga_eho_tsp/data/matrix_loader.py`
- [Dataset registry](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/data/registry.py): `src/ga_eho_tsp/data/registry.py`
- [Benchmark runner](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/experiments/benchmark.py): `src/ga_eho_tsp/experiments/benchmark.py`
- [Benchmark export](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/experiments/export.py): `src/ga_eho_tsp/experiments/export.py`

### Shared domain

- [Problem and configs](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/domain/models.py): `src/ga_eho_tsp/domain/models.py`
- [Route objective](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/domain/objective.py): `src/ga_eho_tsp/domain/objective.py`
- [Permutation operators](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/domain/operators.py): `src/ga_eho_tsp/domain/operators.py`
- [Solver protocol](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/domain/protocols.py): `src/ga_eho_tsp/domain/protocols.py`

### Genetic algorithm

- [GA solver](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/solver.py): `src/ga_eho_tsp/algorithms/ga/solver.py`
- [Population initialization](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/initialization.py): `src/ga_eho_tsp/algorithms/ga/initialization.py`
- [Parent selection](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/selection.py): `src/ga_eho_tsp/algorithms/ga/selection.py`
- [Crossover](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/crossover.py): `src/ga_eho_tsp/algorithms/ga/crossover.py`
- [Mutation](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/mutation.py): `src/ga_eho_tsp/algorithms/ga/mutation.py`
- [2-opt search](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/local_search.py): `src/ga_eho_tsp/algorithms/ga/local_search.py`
- [Run monitoring](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/monitoring.py): `src/ga_eho_tsp/algorithms/ga/monitoring.py`
- [Survivor selection](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/ga/survivor.py): `src/ga_eho_tsp/algorithms/ga/survivor.py`

### Elephant optimization

- [EHO solver](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/eho/solver.py): `src/ga_eho_tsp/algorithms/eho/solver.py`
- [Clan operations](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/eho/clans.py): `src/ga_eho_tsp/algorithms/eho/clans.py`
- [Discrete updates](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/eho/discrete_ops.py): `src/ga_eho_tsp/algorithms/eho/discrete_ops.py`
- [Clan separation](https://github.com/datweb07/ga-eho-tsp/blob/main/src/ga_eho_tsp/algorithms/eho/separation.py): `src/ga_eho_tsp/algorithms/eho/separation.py`

### Other components

- **User**

## Connections

- User → Tk GUI: configures run (evidence: `README.md`)
- User → CLI: starts command (evidence: `README.md`)
- Tk GUI → Matrix loader: loads dataset (evidence: `src/ga_eho_tsp/gui/app.py`)
- Tk GUI → Run controller: starts and polls (evidence: `src/ga_eho_tsp/gui/app.py`)
- Tk GUI → Plots and controls: renders results (evidence: `src/ga_eho_tsp/gui/app.py`)
- Tk GUI → GUI export: exports results (evidence: `src/ga_eho_tsp/gui/app.py`)
- Run controller → GA solver: dispatches solver (evidence: `src/ga_eho_tsp/gui/controller.py`)
- Run controller → EHO solver: dispatches solver (evidence: `src/ga_eho_tsp/gui/controller.py`)
- CLI → Matrix loader: loads dataset (evidence: `src/ga_eho_tsp/cli.py`)
- CLI → GA solver: runs GA (evidence: `src/ga_eho_tsp/cli.py`)
- CLI → EHO solver: runs EHO (evidence: `src/ga_eho_tsp/cli.py`)
- CLI → Benchmark runner: starts benchmark (evidence: `src/ga_eho_tsp/cli.py`)
- Matrix loader → Problem and configs: creates problem (evidence: `src/ga_eho_tsp/data/matrix_loader.py`)
- Benchmark runner → Benchmark export: writes reports
- GA solver → Population initialization: initializes population (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- GA solver → Parent selection: selects parents (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- GA solver → Crossover: creates children (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- GA solver → Mutation: mutates children (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- GA solver → 2-opt search: improves routes (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- GA solver → Run monitoring: records progress (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- GA solver → Survivor selection: chooses survivors (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- GA solver → Problem and configs: uses configs and results (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- GA solver → Route objective: evaluates routes (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- GA solver → Solver protocol: implements contract (evidence: `src/ga_eho_tsp/algorithms/ga/solver.py`)
- EHO solver → Clan operations: updates clans (evidence: `src/ga_eho_tsp/algorithms/eho/solver.py`)
- EHO solver → Discrete updates: updates routes (evidence: `src/ga_eho_tsp/algorithms/eho/solver.py`)
- EHO solver → Clan separation: separates members (evidence: `src/ga_eho_tsp/algorithms/eho/solver.py`)
- EHO solver → Problem and configs: uses configs and results (evidence: `src/ga_eho_tsp/algorithms/eho/solver.py`)
- EHO solver → Route objective: evaluates routes (evidence: `src/ga_eho_tsp/algorithms/eho/solver.py`)
- EHO solver → Permutation operators: initializes routes (evidence: `src/ga_eho_tsp/algorithms/eho/solver.py`)
- EHO solver → Solver protocol: implements contract (evidence: `src/ga_eho_tsp/algorithms/eho/solver.py`)
- Problem and configs → Route objective: validates and scores (evidence: `src/ga_eho_tsp/domain/models.py`)
- Permutation operators → Route objective: uses route type (evidence: `src/ga_eho_tsp/domain/operators.py`)
- Solver protocol → Problem and configs: types solver inputs (evidence: `src/ga_eho_tsp/domain/protocols.py`)
