# hanyangtechai/2026-hai-marl architecture

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

- Interactive diagram: https://gitdiagram.com/hanyangtechai/2026-hai-marl
- Repository: https://github.com/hanyangtechai/2026-hai-marl

## Overview

This repository is a multi-agent bandit research testbed for comparing strategies in non-stationary retail-market simulations. Its principal workflow assembles market arms, runs agents through a collision-penalized evaluator, records Monte Carlo outcomes, and visualizes results. README-documented TrueSkill evaluation and Walmart preprocessing are represented as capabilities, but the tree has no TrueSkill script and the shown sources do not establish their runtime wiring; those connections are therefore omitted. Several agent variants share a subsystem node rather than being listed individually.

Main entry points: [`backup/code/main.py`](https://github.com/hanyangtechai/2026-hai-marl/blob/main/backup/code/main.py) (Monte Carlo runner), [`backup/utils/env_builder.py`](https://github.com/hanyangtechai/2026-hai-marl/blob/main/backup/utils/env_builder.py) (Market builder), [`envs/custom_evaluator.py`](https://github.com/hanyangtechai/2026-hai-marl/blob/main/envs/custom_evaluator.py) (Multi-agent evaluator), [`arms/base_arm.py`](https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/base_arm.py) (Arm interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experiment["Experiment orchestration"]
  node_batch["Monte Carlo runner<br/>[main.py]"]
  node_builder["Market builder<br/>[env_builder.py]"]
  node_evaluator["Multi-agent evaluator"]
  node_legacyeval["SMPyBandits evaluator"]
end

subgraph group_market["Market dynamics"]
  node_walmart["Walmart preprocessing"]
  node_registry["Arm parameters<br/>[arm_registry.py]"]
  node_armbase["Arm interface<br/>[base_arm.py]"]
  node_stationary["Stationary rewards<br/>[stationary_arm.py]"]
  node_shock["Shock rewards<br/>[event_shock_arm.py]"]
  node_trend["Trend rewards<br/>[trend_arm.py]"]
  node_switch["Regime switching<br/>[switch_arm.py]"]
  node_mab["Bandit environment<br/>[MAB.py]"]
end

subgraph group_learning["Agent strategies"]
  node_agentbase["Agent state<br/>[base_agent.py]"]
  node_strategies["Bandit strategies"]
  node_factory["Agent factory<br/>[agent_factory.py]"]
end

subgraph group_analysis["Results and analysis"]
  node_logger["Run logger<br/>[mc_logger.py]"]
  node_batchplots["Batch visualizations"]
  node_paperplots["Paper figures"]
end

node_researcher(("Experiment runner"))

node_researcher -->|"starts runs"| node_batch
node_batch -->|"builds market"| node_builder
node_batch -->|"runs simulation"| node_evaluator
node_batch -->|"records outcomes"| node_logger
node_batch -->|"plots results"| node_batchplots
node_builder -->|"selects parameters"| node_registry
node_builder -->|"constructs arms"| node_stationary
node_builder -->|"constructs arms"| node_shock
node_builder -->|"constructs arms"| node_trend
node_builder -->|"constructs arms"| node_switch
node_builder -->|"assembles environment"| node_mab
node_stationary -->|"inherits interface"| node_armbase
node_shock -->|"inherits interface"| node_armbase
node_trend -->|"inherits interface"| node_armbase
node_switch -->|"inherits interface"| node_armbase
node_evaluator -->|"draws rewards"| node_mab
node_evaluator -.->|"requests choices"| node_strategies
node_evaluator -.->|"updates rewards"| node_agentbase
node_strategies -->|"extends base"| node_agentbase
node_factory -->|"creates agents"| node_strategies
node_batch -.->|"configures lineup"| node_factory
node_walmart -.->|"supplies market features"| node_shock
node_walmart -.->|"supplies regime data"| node_switch
node_legacyeval -->|"evaluates bandits"| node_mab
node_batch -.->|"prepares figures"| node_paperplots

click node_batch "https://github.com/hanyangtechai/2026-hai-marl/blob/main/backup/code/main.py"
click node_builder "https://github.com/hanyangtechai/2026-hai-marl/blob/main/backup/utils/env_builder.py"
click node_evaluator "https://github.com/hanyangtechai/2026-hai-marl/blob/main/envs/custom_evaluator.py"
click node_logger "https://github.com/hanyangtechai/2026-hai-marl/blob/main/utils/mc_logger.py"
click node_batchplots "https://github.com/hanyangtechai/2026-hai-marl/blob/main/utils/plot_batch_results.py"
click node_paperplots "https://github.com/hanyangtechai/2026-hai-marl/blob/main/utils/plot_paper_figures.py"
click node_walmart "https://github.com/hanyangtechai/2026-hai-marl/tree/main/data/walmart"
click node_registry "https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/arm_registry.py"
click node_armbase "https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/base_arm.py"
click node_stationary "https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/stationary_arm.py"
click node_shock "https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/event_shock_arm.py"
click node_trend "https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/trend_arm.py"
click node_switch "https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/switch_arm.py"
click node_mab "https://github.com/hanyangtechai/2026-hai-marl/blob/main/envs/SMPyBandits/Environment/MAB.py"
click node_agentbase "https://github.com/hanyangtechai/2026-hai-marl/blob/main/agents/base_agent.py"
click node_strategies "https://github.com/hanyangtechai/2026-hai-marl/tree/main/agents"
click node_factory "https://github.com/hanyangtechai/2026-hai-marl/blob/main/backup/utils/agent_factory.py"
click node_legacyeval "https://github.com/hanyangtechai/2026-hai-marl/blob/main/envs/SMPyBandits/Environment/EvaluatorMultiPlayers.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_batch,node_builder,node_evaluator,node_legacyeval toneBlue
class node_walmart,node_registry,node_armbase,node_stationary,node_shock,node_trend,node_switch,node_mab toneAmber
class node_agentbase,node_strategies,node_factory toneMint
class node_logger,node_batchplots,node_paperplots toneRose
class node_researcher toneIndigo
```

## Components

### Experiment orchestration

- [Monte Carlo runner](https://github.com/hanyangtechai/2026-hai-marl/blob/main/backup/code/main.py): `backup/code/main.py`
- [Market builder](https://github.com/hanyangtechai/2026-hai-marl/blob/main/backup/utils/env_builder.py): `backup/utils/env_builder.py`
- [Multi-agent evaluator](https://github.com/hanyangtechai/2026-hai-marl/blob/main/envs/custom_evaluator.py): `envs/custom_evaluator.py`
- [SMPyBandits evaluator](https://github.com/hanyangtechai/2026-hai-marl/blob/main/envs/SMPyBandits/Environment/EvaluatorMultiPlayers.py): `envs/SMPyBandits/Environment/EvaluatorMultiPlayers.py`

### Market dynamics

- [Walmart preprocessing](https://github.com/hanyangtechai/2026-hai-marl/tree/main/data/walmart): `data/walmart`
- [Arm parameters](https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/arm_registry.py): `arms/arm_registry.py`
- [Arm interface](https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/base_arm.py): `arms/base_arm.py`
- [Stationary rewards](https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/stationary_arm.py): `arms/stationary_arm.py`
- [Shock rewards](https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/event_shock_arm.py): `arms/event_shock_arm.py`
- [Trend rewards](https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/trend_arm.py): `arms/trend_arm.py`
- [Regime switching](https://github.com/hanyangtechai/2026-hai-marl/blob/main/arms/switch_arm.py): `arms/switch_arm.py`
- [Bandit environment](https://github.com/hanyangtechai/2026-hai-marl/blob/main/envs/SMPyBandits/Environment/MAB.py): `envs/SMPyBandits/Environment/MAB.py`

### Agent strategies

- [Agent state](https://github.com/hanyangtechai/2026-hai-marl/blob/main/agents/base_agent.py): `agents/base_agent.py`
- [Bandit strategies](https://github.com/hanyangtechai/2026-hai-marl/tree/main/agents): `agents`
- [Agent factory](https://github.com/hanyangtechai/2026-hai-marl/blob/main/backup/utils/agent_factory.py): `backup/utils/agent_factory.py`

### Results and analysis

- [Run logger](https://github.com/hanyangtechai/2026-hai-marl/blob/main/utils/mc_logger.py): `utils/mc_logger.py`
- [Batch visualizations](https://github.com/hanyangtechai/2026-hai-marl/blob/main/utils/plot_batch_results.py): `utils/plot_batch_results.py`
- [Paper figures](https://github.com/hanyangtechai/2026-hai-marl/blob/main/utils/plot_paper_figures.py): `utils/plot_paper_figures.py`

### Other components

- **Experiment runner**

## Connections

- Experiment runner → Monte Carlo runner: starts runs (evidence: `backup/code/main.py`)
- Monte Carlo runner → Market builder: builds market (evidence: `backup/code/main.py`)
- Monte Carlo runner → Multi-agent evaluator: runs simulation (evidence: `backup/code/main.py`)
- Monte Carlo runner → Run logger: records outcomes (evidence: `backup/code/main.py`)
- Monte Carlo runner → Batch visualizations: plots results (evidence: `backup/code/main.py`)
- Market builder → Arm parameters: selects parameters (evidence: `backup/utils/env_builder.py`)
- Market builder → Stationary rewards: constructs arms (evidence: `backup/utils/env_builder.py`)
- Market builder → Shock rewards: constructs arms (evidence: `backup/utils/env_builder.py`)
- Market builder → Trend rewards: constructs arms (evidence: `backup/utils/env_builder.py`)
- Market builder → Regime switching: constructs arms (evidence: `backup/utils/env_builder.py`)
- Market builder → Bandit environment: assembles environment (evidence: `backup/utils/env_builder.py`)
- Stationary rewards → Arm interface: inherits interface (evidence: `arms/stationary_arm.py`)
- Shock rewards → Arm interface: inherits interface (evidence: `arms/event_shock_arm.py`)
- Trend rewards → Arm interface: inherits interface (evidence: `arms/trend_arm.py`)
- Regime switching → Arm interface: inherits interface (evidence: `arms/switch_arm.py`)
- Multi-agent evaluator → Bandit environment: draws rewards (evidence: `envs/custom_evaluator.py`)
- Multi-agent evaluator → Bandit strategies: requests choices
- Multi-agent evaluator → Agent state: updates rewards
- Bandit strategies → Agent state: extends base (evidence: `agents/as_ucb.py`)
- Agent factory → Bandit strategies: creates agents (evidence: `backup/utils/agent_factory.py`)
- Monte Carlo runner → Agent factory: configures lineup
- Walmart preprocessing → Shock rewards: supplies market features
- Walmart preprocessing → Regime switching: supplies regime data
- SMPyBandits evaluator → Bandit environment: evaluates bandits (evidence: `envs/SMPyBandits/Environment/EvaluatorMultiPlayers.py`)
- Monte Carlo runner → Paper figures: prepares figures
