# cuongtv312/marl-delivery architecture

> Architecture diagram of the GitHub repository cuongtv312/marl-delivery, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cuongtv312/marl-delivery
- Repository: https://github.com/cuongtv312/marl-delivery

## Overview

##### Project type and purpose
- This is an open-source, multi-agent reinforcement learning (MARL) simulation tool for package delivery.
- It provides two agent types: a BFS-based greedy agent (`greedyagent.py`) and a PPO-based RL agent (`simple_PPO.ipynb`), all orchestrated via a command-line interface in `main.py`.

##### File structure
- Top-level scripts:
- `main.py` – CLI entry point to launch experiments.
- `agent.py` – Base/abstract agent class defining the agent interface.
- `greedyagent.py` – Concrete implementation of a BFS-driven greedy agent.
- `env.py` – Defines the `Env` class: simulation engine, observation/state conversion, reward shaping, step/reset logic.
- Data / resources:
- `map.txt`, `map1.txt` … `map5.txt` – Environment configuration files (grid layouts).
- Experiment/training:
- `simple_PPO.ipynb` – Jupyter notebook to train/test RL (PPO) agents.
- Metadata:
- `requirements.txt`, `LICENSE`, `README.md`, `Group-Project.pdf`.
- No separate “frontend” or “backend”: this is a single-process Python application.

##### README for additional insights
- It describes five test configurations (map files, seed, steps, agents, packages).
- It recommends not modifying `Env` class core logic, but allowing tweaks to `convert_state` or `reward_shaping`.
- It highlights BFS vs. RL performance comparisons.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration Layer
    CLI["CLI Interface / Experiment Runner\n(main.py)"]:::cli
    click CLI "https://github.com/cuongtv312/marl-delivery/blob/master/main.py"

    %% Core Engine
    Env["Simulation Engine\nEnv"]:::engine
    click Env "https://github.com/cuongtv312/marl-delivery/blob/master/env.py"

    %% Agent Layer
    BaseAgent["BaseAgent Interface"]:::agent
    click BaseAgent "https://github.com/cuongtv312/marl-delivery/blob/master/agent.py"
    GreedyAgent["GreedyAgent (BFS)"]:::agent
    click GreedyAgent "https://github.com/cuongtv312/marl-delivery/blob/master/greedyagent.py"
    PPOAgent["PPO Agent (RL)"]:::agent
    click PPOAgent "https://github.com/cuongtv312/marl-delivery/blob/master/simple_PPO.ipynb"

    %% Logging
    Logger["Metrics Logger"]:::logger

    %% Resources
    subgraph "Map Configurations" 
        direction TB
        Map0["map.txt"]:::resource
        click Map0 "https://github.com/cuongtv312/marl-delivery/blob/master/map.txt"
        Map1["map1.txt"]:::resource
        click Map1 "https://github.com/cuongtv312/marl-delivery/blob/master/map1.txt"
        Map2["map2.txt"]:::resource
        click Map2 "https://github.com/cuongtv312/marl-delivery/blob/master/map2.txt"
        Map3["map3.txt"]:::resource
        click Map3 "https://github.com/cuongtv312/marl-delivery/blob/master/map3.txt"
        Map4["map4.txt"]:::resource
        click Map4 "https://github.com/cuongtv312/marl-delivery/blob/master/map4.txt"
        Map5["map5.txt"]:::resource
        click Map5 "https://github.com/cuongtv312/marl-delivery/blob/master/map5.txt"
    end

    subgraph "External Dependencies" 
        direction TB
        Req["requirements.txt"]:::resource
        click Req "https://github.com/cuongtv312/marl-delivery/blob/master/requirements.txt"
    end

    subgraph "Project Documentation" 
        direction TB
        Readme["README.md"]:::docs
        click Readme "https://github.com/cuongtv312/marl-delivery/blob/master/README.md"
        License["LICENSE"]:::docs
        click License "https://github.com/cuongtv312/marl-delivery/tree/master/LICENSE"
        PDF["Group-Project.pdf"]:::docs
        click PDF "https://github.com/cuongtv312/marl-delivery/blob/master/Group-Project.pdf"
    end

    %% Relationships
    CLI -->|"load config, seed, params"| Env
    CLI -->|"instantiate agents"| BaseAgent
    BaseAgent -->|extends| GreedyAgent
    BaseAgent -->|extends| PPOAgent
    BaseAgent -->|requests action| Env
    Env -->|"state, reward"| BaseAgent
    Env -->|"log metrics"| Logger
    CLI -->|"select map file"| Map0
    CLI -->|"select map file"| Map1
    CLI -->|"select map file"| Map2
    CLI -->|"select map file"| Map3
    CLI -->|"select map file"| Map4
    CLI -->|"select map file"| Map5

    %% Styles
    classDef cli fill:#dddddd,stroke:#333,stroke-width:1px
    classDef engine fill:#cce5ff,stroke:#0066cc,stroke-width:1px
    classDef agent fill:#d4edda,stroke:#28a745,stroke-width:1px
    classDef resource fill:#fff3cd,stroke:#ffcc00,stroke-width:1px
    classDef docs fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
    classDef logger fill:#f8d7da,stroke:#dc3545,stroke-width:1px
```
