How zefang-liu/invagent works
Project Type and Purpose
• Type: Research codebase for multi-agent reinforcement-learning in supply chains, enhanced by LLM calls.
• Purpose: Simulate inventory environments, run baseline/IPPO/MAPPO policies (zero-shot via LLMs), and compare performance.
File Structure
• notebooks/
– autogen.ipynb: orchestration of experiments (data loading, running episodes, result plotting).
• src/
– env.py: defines the supply-chain environment logic (state, step, reset).
– config.py: central configuration loader (agent counts, horizons, LLM settings).
– baseline.py: rule-based inventory policy implementation.
– ippo.py: Independent PPO multi-agent algorithm (no communication).
– mappo.py: Multi-agent PPO with parameter sharing or coordination.
• requirements.txt: external libraries, including OpenAI packages.
README for Additional Insights
• LLM Integration: Agents can query OpenAI API (zero-shot prompts) at each decision point.
• Experiment Workflow: Notebook → load config → init env + agents → run episodes → collect metrics.
Main Components and Their Interactions
a. Components:
1. External LLM Service (OpenAI API)
2. Experiment Orchestrator (notebooks/autogen.ipynb)
3. Configuration Module (src/config.py)
4. Environment Simulator (src/env.py)
5. Agent Policies:
• Baseline (src/baseline.py)
• IPPO (src/ippo.py)
• MAPPO (src/mappo.py)
6. Results Store / Metrics Logger (in-memory or file outputs)
b. Relationships & Data Flow:
1. The notebook loads config → instantiates env + selected policy class.
2. For each timestep:
– env.py exposes state to policy module.
– If policy uses LLM: policy sends prompt → OpenAI API → returns action.
– Otherwise, policy computes action locally.
– Action flows back to env → env.step() → new state + reward.
3. Logger collects (state, action, reward) → results files/plots.
c. Architectural Patterns:
• Modular policy plugging (Strategy pattern): baseline/IPPO/MAPPO share a common interface.
• Experiment orchestrator decoupled from core logic (Separation of concerns).
• Configuration-driven initialization.
d. Key Technologies:
• Python 3.x
• OpenAI Python SDK (LLM calls)
• RL libraries or NumPy/Pandas (for IPPO/MAPPO math)
• Jupyter notebooks for orchestration and visualization.
Detailed Checklist
• Break out each src/*.py as its own component.
• Config.py feeding parameters into env.py and policy constructors.
• Decision loop: state → policy → action → environment.
• Denote zero-shot LLM invocation path separately from local policy logic.
• Notebook’s role in orchestrating runs and gathering plots.