# czh0312/pi-vrptw-pdp architecture

> Architecture diagram of the GitHub repository czh0312/pi-vrptw-pdp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/czh0312/pi-vrptw-pdp
- Repository: https://github.com/czh0312/pi-vrptw-pdp

## Overview

This repository is a two-echelon vehicle-routing and reusable-container optimization suite. Its principal workflow is to select a routing model and solver, optimize delivery routes (and, for circular multi-batch models, recovery, batch timing, and container-pool use), then audit or compare results and optionally calculate lifecycle economics. The README documents eight model variants, MILP and ALNS approaches, and cost analysis. The graph uses documented capabilities and indexed source references; unsampled implementation details and runtime wiring are not asserted.

Main entry points: [`cli/main.py`](https://github.com/czh0312/pi-vrptw-pdp/blob/main/cli/main.py) (CLI dispatcher), [`models/routing/service.py`](https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/routing/service.py) (Routing service), [`cli/route.py`](https://github.com/czh0312/pi-vrptw-pdp/blob/main/cli/route.py) (Route command), [`experiments/runs/run_multibatch_cycle.py`](https://github.com/czh0312/pi-vrptw-pdp/blob/main/experiments/runs/run_multibatch_cycle.py) (Multi-batch studies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_dispatcher["CLI dispatcher<br/>[main.py]"]
  node_route_cli["Route command<br/>[route.py]"]
  node_cost_cli["Cost command<br/>[cost.py]"]
end

subgraph group_routing["Routing optimization"]
  node_routing_service["Routing service<br/>[service.py]"]
  node_model_catalog["Model catalog<br/>[catalog.py]"]
  node_single_models["M1–M4 models"]
  node_multibatch_models["M5–M8 models"]
  node_alns["ALNS solvers"]
  node_exact["MILP solvers"]
end

subgraph group_domain["Shared domain"]
  node_instances["Routing instances<br/>[instance.py]"]
  node_operating_policy["Operating policy"]
  node_cycle_calendar["Cycle and calendar<br/>[calendar.py]"]
  node_cycle_audit["Cycle audit<br/>[audit.py]"]
end

subgraph group_economics["Economics and studies"]
  node_cost_models["Cost analysis<br/>[lifecycle.py]"]
  node_multibatch_studies["Multi-batch studies"]
  node_single_batch_studies["Single-batch studies"]
  node_model6_studies["M6 comparisons"]
end

node_user(("Operator"))

node_user -->|"invokes"| node_dispatcher
node_dispatcher -->|"dispatches"| node_route_cli
node_dispatcher -->|"dispatches"| node_cost_cli
node_dispatcher -->|"dispatches"| node_multibatch_studies
node_dispatcher -->|"dispatches"| node_single_batch_studies
node_routing_service -->|"references"| node_model_catalog
node_routing_service -->|"references"| node_operating_policy
node_routing_service -->|"references"| node_cycle_calendar
node_route_cli -->|"references"| node_cycle_calendar
node_route_cli -->|"references"| node_multibatch_studies
node_single_models -->|"offers"| node_alns
node_single_models -->|"offers"| node_exact
node_multibatch_models -->|"offers"| node_alns
node_multibatch_models -->|"offers"| node_exact
node_multibatch_studies -->|"uses"| node_cycle_audit
node_model6_studies -->|"references"| node_cycle_audit
node_model6_studies -->|"references"| node_cost_models
node_cost_cli -->|"references"| node_cost_models

click node_dispatcher "https://github.com/czh0312/pi-vrptw-pdp/blob/main/cli/main.py"
click node_route_cli "https://github.com/czh0312/pi-vrptw-pdp/blob/main/cli/route.py"
click node_cost_cli "https://github.com/czh0312/pi-vrptw-pdp/blob/main/cli/cost.py"
click node_routing_service "https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/routing/service.py"
click node_model_catalog "https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/routing/catalog.py"
click node_single_models "https://github.com/czh0312/pi-vrptw-pdp/tree/main/models/routing/model_1"
click node_multibatch_models "https://github.com/czh0312/pi-vrptw-pdp/tree/main/models/routing/model_5"
click node_alns "https://github.com/czh0312/pi-vrptw-pdp/tree/main/models/routing/model_1/alns"
click node_exact "https://github.com/czh0312/pi-vrptw-pdp/tree/main/models/routing/model_1/exact"
click node_instances "https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/common/domain/instance.py"
click node_operating_policy "https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/common/operating_policy.py"
click node_cycle_calendar "https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/common/cycle/calendar.py"
click node_cycle_audit "https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/common/cycle/audit.py"
click node_cost_models "https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/cost/lifecycle.py"
click node_multibatch_studies "https://github.com/czh0312/pi-vrptw-pdp/blob/main/experiments/runs/run_multibatch_cycle.py"
click node_single_batch_studies "https://github.com/czh0312/pi-vrptw-pdp/blob/main/experiments/runs/run_single_batch_comparison.py"
click node_model6_studies "https://github.com/czh0312/pi-vrptw-pdp/blob/main/experiments/runs/run_model6_comparison.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_dispatcher,node_route_cli,node_cost_cli toneBlue
class node_routing_service,node_model_catalog,node_single_models,node_multibatch_models,node_alns,node_exact toneAmber
class node_instances,node_operating_policy,node_cycle_calendar,node_cycle_audit toneMint
class node_cost_models,node_multibatch_studies,node_single_batch_studies,node_model6_studies toneRose
class node_user toneIndigo
```

## Components

### User entry

- [CLI dispatcher](https://github.com/czh0312/pi-vrptw-pdp/blob/main/cli/main.py): `cli/main.py`
- [Route command](https://github.com/czh0312/pi-vrptw-pdp/blob/main/cli/route.py): `cli/route.py`
- [Cost command](https://github.com/czh0312/pi-vrptw-pdp/blob/main/cli/cost.py): `cli/cost.py`

### Routing optimization

- [Routing service](https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/routing/service.py): `models/routing/service.py`
- [Model catalog](https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/routing/catalog.py): `models/routing/catalog.py`
- [M1–M4 models](https://github.com/czh0312/pi-vrptw-pdp/tree/main/models/routing/model_1): `models/routing/model_1`
- [M5–M8 models](https://github.com/czh0312/pi-vrptw-pdp/tree/main/models/routing/model_5): `models/routing/model_5`
- [ALNS solvers](https://github.com/czh0312/pi-vrptw-pdp/tree/main/models/routing/model_1/alns): `models/routing/model_1/alns`
- [MILP solvers](https://github.com/czh0312/pi-vrptw-pdp/tree/main/models/routing/model_1/exact): `models/routing/model_1/exact`

### Shared domain

- [Routing instances](https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/common/domain/instance.py): `models/common/domain/instance.py`
- [Operating policy](https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/common/operating_policy.py): `models/common/operating_policy.py`
- [Cycle and calendar](https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/common/cycle/calendar.py): `models/common/cycle/calendar.py`
- [Cycle audit](https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/common/cycle/audit.py): `models/common/cycle/audit.py`

### Economics and studies

- [Cost analysis](https://github.com/czh0312/pi-vrptw-pdp/blob/main/models/cost/lifecycle.py): `models/cost/lifecycle.py`
- [Multi-batch studies](https://github.com/czh0312/pi-vrptw-pdp/blob/main/experiments/runs/run_multibatch_cycle.py): `experiments/runs/run_multibatch_cycle.py`
- [Single-batch studies](https://github.com/czh0312/pi-vrptw-pdp/blob/main/experiments/runs/run_single_batch_comparison.py): `experiments/runs/run_single_batch_comparison.py`
- [M6 comparisons](https://github.com/czh0312/pi-vrptw-pdp/blob/main/experiments/runs/run_model6_comparison.py): `experiments/runs/run_model6_comparison.py`

### Other components

- **Operator**

## Connections

- Operator → CLI dispatcher: invokes (evidence: `README.md`)
- CLI dispatcher → Route command: dispatches (evidence: `cli/main.py`)
- CLI dispatcher → Cost command: dispatches (evidence: `cli/main.py`)
- CLI dispatcher → Multi-batch studies: dispatches (evidence: `cli/main.py`)
- CLI dispatcher → Single-batch studies: dispatches (evidence: `cli/main.py`)
- Routing service → Model catalog: references (evidence: `models/routing/service.py`)
- Routing service → Operating policy: references (evidence: `models/routing/service.py`)
- Routing service → Cycle and calendar: references (evidence: `models/routing/service.py`)
- Route command → Cycle and calendar: references (evidence: `cli/route.py`)
- Route command → Multi-batch studies: references (evidence: `cli/route.py`)
- M1–M4 models → ALNS solvers: offers (evidence: `README.md`)
- M1–M4 models → MILP solvers: offers (evidence: `README.md`)
- M5–M8 models → ALNS solvers: offers (evidence: `README.md`)
- M5–M8 models → MILP solvers: offers (evidence: `README.md`)
- Multi-batch studies → Cycle audit: uses (evidence: `experiments/runs/run_multibatch_cycle.py`)
- M6 comparisons → Cycle audit: references (evidence: `experiments/runs/run_model6_comparison.py`)
- M6 comparisons → Cost analysis: references (evidence: `experiments/runs/run_model6_comparison.py`)
- Cost command → Cost analysis: references (evidence: `cli/cost.py`)
