# jtidbury2/thirdyearproject-autonomousintersectionmanagment architecture

> Architecture diagram of the GitHub repository jtidbury2/thirdyearproject-autonomousintersectionmanagment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jtidbury2/thirdyearproject-autonomousintersectionmanagment
- Repository: https://github.com/jtidbury2/thirdyearproject-autonomousintersectionmanagment

## Overview

- JavaSim – the original AIM simulator, used as a blueprint (even though it’s no longer used directly).
- PettingZooSim – a PettingZoo-based environment specifically set up to train deep reinforcement learning agents on highway and intersection scenarios.
- PythonSim – an extended intersection simulation (derived from an open–source simulator) that seems to provide the main engine for running the research simulations.

a. The “Blueprint/Reference Simulator” component using JavaSim.
b. The “Deep RL Simulation Environment” via PettingZooSim, which itself is subdivided into modules such as:
– HighwayEnv (with its environments, vehicle dynamics, road models, etc.).
– Documentation and test suites (helpful to understand simulation parameters).
c. The “Research Simulator and UI” through PythonSim, which includes the simulation engine, settings (lib/settings.py), visualization (my_main_window.py, my_paint_canvas.py), logging, and execution components.
d. The “Reinforcement Learning Agents” component from rl-agents. This part shows multiple agent types (DQN, MCTS, budgeted_ftq, etc.) with configurations for various environments provided via a rich set of JSON configuration files.

##### Interactions and data flows
– The research workflow appears to start by configuring the RL agents (using rl-agents and helper scripts) and then training/validating them using the environments provided by PettingZooSim.
– Simulation results and evaluation logs are generated by both PettingZooSim (with numerous “scripts/” and “tests” folders) and PythonSim (which contains experiment run files, logging, and visualization scripts).

##### Architectural patterns and design principles
– There is a clear separation of concerns: simulation engine (PythonSim), environment definition and agent training (PettingZooSim with its “highway_env” and multi-agent configurations), and agent definitions (rl-agents).
– The design also reflects modularity. For example, runtime configurations and experiment scripts for RL experiments are separately organized (notice the multiple “configs” directories under rl-agents/scripts) ensuring that different strategies or environments can be plugged into the simulation.
– Testing and documentation are an integral part (with numerous tests and docs directories), indicating a robust development process.

##### Relevant technologies and libraries
– For PettingZooSim, the underlying PettingZoo library is the basis.
– In rl-agents, deep RL implementations are provided in frameworks like PyTorch (as seen in files such as pytorch.py).
– PythonSim closely overlaps with traditional simulation software design – incorporating GUI elements and logging, likely using Python’s standard libraries along with custom modules (e.g., my_main_window, my_paint_canvas).
– Build and configuration files (like setup.py, pyproject.toml, Makefile in docs) underline that package management and documentation generation are part of the design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% High-Level Subsystems
    subgraph "Legacy & Blueprint"
        A["JavaSim (AIM Blueprint)"]:::blueprint
    end

    subgraph "Deep RL Simulation Environment"
        B["PettingZooSim (RL Environment)"]:::environment
        B1["HighwayEnv (Environment Modules)"]:::environment
        B2["Documentation & Testing"]:::environment
    end

    subgraph "Research Simulator & UI"
        C["PythonSim (Engine & UI)"]:::engine
        C1["Settings (lib)"]:::engine
        C2["Main Window (Visualization)"]:::engine
        C3["Paint Canvas (Visualization)"]:::engine
        C4["Logging & Execution"]:::engine
    end

    subgraph "Reinforcement Learning Agents"
        D["rl-agents (RL Agent Suite)"]:::agents
        D1["Agent Configurations (JSON)"]:::agents
    end

    %% Data Flows and Interactions
    D1 -->|"configuresAgents"| D
    D -->|"trainsThroughEnvironment"| B
    B -->|"providesObservationsTo"| C
    A -->|"inspiresDesignFor"| C
    C -->|"logsResultsTo"| B2

    %% Class Definitions for Styling
    classDef blueprint fill:#E0E0E0,stroke:#000,stroke-width:2px;
    classDef environment fill:#C6E2FF,stroke:#000,stroke-width:2px;
    classDef engine fill:#C1FFC1,stroke:#000,stroke-width:2px;
    classDef agents fill:#FFDAB9,stroke:#000,stroke-width:2px;

    %% Click Events for Component Mappings
    click A "https://github.com/jtidbury2/thirdyearproject-autonomousintersectionmanagment/tree/master/JavaSim"
    click B1 "https://github.com/jtidbury2/thirdyearproject-autonomousintersectionmanagment/tree/master/PettingZooSim/HighwayEnv"
    click C1 "https://github.com/jtidbury2/thirdyearproject-autonomousintersectionmanagment/blob/master/PythonSim/lib/settings.py"
    click C2 "https://github.com/jtidbury2/thirdyearproject-autonomousintersectionmanagment/blob/master/PythonSim/my_main_window.py"
    click C3 "https://github.com/jtidbury2/thirdyearproject-autonomousintersectionmanagment/blob/master/PythonSim/my_paint_canvas.py"
    click D "https://github.com/jtidbury2/thirdyearproject-autonomousintersectionmanagment/tree/master/PettingZooSim/rl-agents"
```
