# mal4vrp/maenvs4vrp architecture

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

- Interactive diagram: https://gitdiagram.com/mal4vrp/maenvs4vrp
- Repository: https://github.com/mal4vrp/maenvs4vrp

## Overview

MAEnvs4VRP is a multi-agent vehicle-routing simulation and reinforcement-learning library. A user configures a problem environment and instance generator, resets to obtain observations, selects feasible agent actions, and receives updated state and reward. The repository provides sequential and batched variants, many routing-problem families, and neural solver baselines. The graph groups problem families rather than listing every near-parallel implementation; sampled source and the README support the shown links, while details of unsampled family implementations are not asserted.

Main entry points: [`maenvs4vrp/parallel_environments`](https://github.com/mal4vrp/maenvs4vrp/tree/master/maenvs4vrp/parallel_environments) (Parallel Environments), [`maenvs4vrp/environments`](https://github.com/mal4vrp/maenvs4vrp/tree/master/maenvs4vrp/environments) (Sequential Environments), [`maenvs4vrp/neuro_solvers/attention_model`](https://github.com/mal4vrp/maenvs4vrp/tree/master/maenvs4vrp/neuro_solvers/attention_model) (Attention Training), [`maenvs4vrp/neuro_solvers/two_d_ptr/train_reinforce_shared_baseline.py`](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/neuro_solvers/two_d_ptr/train_reinforce_shared_baseline.py) (Pointer Training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Environment Core"]
  node_instances["Instance Builders"]
  node_observations["Observation Builder"]
  node_aec["AEC Environment<br/>[env.py]"]
  node_agent_selector["Agent Selector"]
  node_reward["Reward Evaluator"]
end

subgraph group_problems["Routing Problems"]
  node_sequential["Sequential Environments"]
end

subgraph group_batch["Batched Environments"]
  node_parallel_family["Parallel Environments"]
  node_parallel_core["Parallel Base<br/>[parallel_env.py]"]
end

subgraph group_solvers["Neural Solvers"]
  node_attention["Attention Model<br/>[policy_net_am.py]"]
  node_attention_training["Attention Training"]
  node_pointer["2D Pointer Model"]
  node_pointer_training["Pointer Training"]
end

subgraph group_utilities["Shared Utilities"]
  node_ops["Routing Operations<br/>[ops.py]"]
end

node_user(("Environment User"))

node_user -->|"configures"| node_sequential
node_user -->|"chooses batch"| node_parallel_family
node_sequential -->|"uses builders"| node_instances
node_sequential -->|"uses builder"| node_observations
node_sequential -->|"uses selector"| node_agent_selector
node_sequential -->|"uses evaluator"| node_reward
node_sequential -->|"extends base"| node_aec
node_parallel_family -->|"extends base"| node_parallel_core
node_parallel_family -->|"uses builders"| node_instances
node_parallel_family -->|"uses builder"| node_observations
node_parallel_family -->|"uses evaluator"| node_reward
node_sequential -->|"calls utilities"| node_ops
node_parallel_family -->|"calls utilities"| node_ops
node_attention_training -->|"trains model"| node_attention
node_pointer_training -->|"trains model"| node_pointer
node_attention_training -->|"trains on"| node_parallel_family
node_pointer_training -->|"trains on"| node_parallel_family

click node_sequential "https://github.com/mal4vrp/maenvs4vrp/tree/master/maenvs4vrp/environments"
click node_instances "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env_generator_builder.py"
click node_observations "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env_observation_builder.py"
click node_aec "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env.py"
click node_agent_selector "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env_agent_selector.py"
click node_reward "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env_agent_reward.py"
click node_parallel_family "https://github.com/mal4vrp/maenvs4vrp/tree/master/maenvs4vrp/parallel_environments"
click node_parallel_core "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/parallel_env.py"
click node_attention "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/neuro_solvers/attention_model/policy_net_am.py"
click node_attention_training "https://github.com/mal4vrp/maenvs4vrp/tree/master/maenvs4vrp/neuro_solvers/attention_model"
click node_pointer "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/neuro_solvers/two_d_ptr/td_pointer_model.py"
click node_pointer_training "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/neuro_solvers/two_d_ptr/train_reinforce_shared_baseline.py"
click node_ops "https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/utils/ops.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_instances,node_observations,node_aec,node_agent_selector,node_reward,node_user toneBlue
class node_sequential toneAmber
class node_parallel_family,node_parallel_core toneMint
class node_attention,node_attention_training,node_pointer,node_pointer_training toneRose
class node_ops toneIndigo
```

## Components

### Environment Core

- [Instance Builders](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env_generator_builder.py): `maenvs4vrp/core/env_generator_builder.py`
- [Observation Builder](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env_observation_builder.py): `maenvs4vrp/core/env_observation_builder.py`
- [AEC Environment](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env.py): `maenvs4vrp/core/env.py`
- [Agent Selector](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env_agent_selector.py): `maenvs4vrp/core/env_agent_selector.py`
- [Reward Evaluator](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/env_agent_reward.py): `maenvs4vrp/core/env_agent_reward.py`

### Routing Problems

- [Sequential Environments](https://github.com/mal4vrp/maenvs4vrp/tree/master/maenvs4vrp/environments): `maenvs4vrp/environments`

### Batched Environments

- [Parallel Environments](https://github.com/mal4vrp/maenvs4vrp/tree/master/maenvs4vrp/parallel_environments): `maenvs4vrp/parallel_environments`
- [Parallel Base](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/core/parallel_env.py): `maenvs4vrp/core/parallel_env.py`

### Neural Solvers

- [Attention Model](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/neuro_solvers/attention_model/policy_net_am.py): `maenvs4vrp/neuro_solvers/attention_model/policy_net_am.py`
- [Attention Training](https://github.com/mal4vrp/maenvs4vrp/tree/master/maenvs4vrp/neuro_solvers/attention_model): `maenvs4vrp/neuro_solvers/attention_model`
- [2D Pointer Model](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/neuro_solvers/two_d_ptr/td_pointer_model.py): `maenvs4vrp/neuro_solvers/two_d_ptr/td_pointer_model.py`
- [Pointer Training](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/neuro_solvers/two_d_ptr/train_reinforce_shared_baseline.py): `maenvs4vrp/neuro_solvers/two_d_ptr/train_reinforce_shared_baseline.py`

### Shared Utilities

- [Routing Operations](https://github.com/mal4vrp/maenvs4vrp/blob/master/maenvs4vrp/utils/ops.py): `maenvs4vrp/utils/ops.py`

### Other components

- **Environment User**

## Connections

- Environment User → Sequential Environments: configures
- Environment User → Parallel Environments: chooses batch
- Sequential Environments → Instance Builders: uses builders (evidence: `maenvs4vrp/environments/gmtdvrp/env.py`)
- Sequential Environments → Observation Builder: uses builder (evidence: `maenvs4vrp/environments/gmtdvrp/env.py`)
- Sequential Environments → Agent Selector: uses selector (evidence: `maenvs4vrp/environments/gmtdvrp/env.py`)
- Sequential Environments → Reward Evaluator: uses evaluator (evidence: `maenvs4vrp/environments/gmtdvrp/env.py`)
- Sequential Environments → AEC Environment: extends base (evidence: `maenvs4vrp/environments/gmtdvrp/env.py`)
- Parallel Environments → Parallel Base: extends base (evidence: `maenvs4vrp/parallel_environments/pcvrptw/env.py`)
- Parallel Environments → Instance Builders: uses builders (evidence: `maenvs4vrp/parallel_environments/pcvrptw/env.py`)
- Parallel Environments → Observation Builder: uses builder (evidence: `maenvs4vrp/parallel_environments/pcvrptw/env.py`)
- Parallel Environments → Reward Evaluator: uses evaluator (evidence: `maenvs4vrp/parallel_environments/pcvrptw/env.py`)
- Sequential Environments → Routing Operations: calls utilities (evidence: `maenvs4vrp/environments/gmtdvrp/env.py`)
- Parallel Environments → Routing Operations: calls utilities (evidence: `maenvs4vrp/parallel_environments/pcvrptw/env.py`)
- Attention Training → Attention Model: trains model (evidence: `maenvs4vrp/neuro_solvers/attention_model/train_ppo.py`)
- Pointer Training → 2D Pointer Model: trains model (evidence: `maenvs4vrp/neuro_solvers/two_d_ptr/train_reinforce_shared_baseline.py`)
- Attention Training → Parallel Environments: trains on
- Pointer Training → Parallel Environments: trains on
