Commit 11f92151 authored by Barthelet Thibault's avatar Barthelet Thibault
Browse files

first commit

parents
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+5 −0
Original line number Diff line number Diff line
/aa_venv
/archives
/supply_chain_sim.egg-info
/venv
 No newline at end of file

README.md

0 → 100644
+126 −0
Original line number Diff line number Diff line
# Supply Chain Simulation - Watch Industry

A comprehensive supply chain simulation for the watch industry, implementing demand forecasting, supply planning, assembly, distribution, and customer behavior modeling.

## Installation

1. Clone or download the project files
2. Install in development mode:

```bash
pip install -e .
```

Or install dependencies directly:

```bash
pip install -r requirements.txt
```

## Project Structure

```
supply_chain_sim/
├── __init__.py              # Package initialization
├── entities.py              # Data models (Brand, Supplier, Customer, etc.)
├── synthetic_setup.py       # Generate synthetic entities
├── forecasting.py           # Demand forecasting with ML
├── supply_order.py          # Supply order logic and planning
├── event_injection.py       # Internal/external event management
├── assembly.py              # Component flow and watch assembly
├── distribution.py          # Retail distribution logic
├── customer_behavior.py     # Customer purchase simulation
├── model_update.py          # AI model updates and tracking
├── research_logging.py      # KPI tracking and reporting
└── simulation.py            # Main simulation orchestrator
```

## Usage

### Basic Run

```bash
python run_simulation.py
```

### With Custom Parameters

```bash
python run_simulation.py --days 60 --customers 1000 --retailers 10 --seed 123
```

### Command Line Options

- `--days`: Number of simulation days (default: 30)
- `--customers`: Number of customers (default: 500)
- `--retailers`: Number of retailers (default: 6)
- `--seed`: Random seed for reproducibility (default: 42)
- `--debug`: Enable debug logging

### Programmatic Usage

```python
from supply_chain_sim import run_oneshot_simulation

# Custom configuration
config = {
    'seed': 42,
    'n_brands': 2,
    'n_suppliers': 5,
    'n_components': 15,
    'n_watches': 8,
    'n_warehouses': 2,
    'n_retailers': 6,
    'n_customers': 500,
    'simulation_days': 30,
    'timestep_days': 1
}

# Run simulation
simulation = run_oneshot_simulation(config)
```

## Key Features

1. **Synthetic Entity Generation**: Creates brands, suppliers, customers, watches with realistic distributions
2. **Demand Forecasting**: ML-based demand prediction with uncertainty intervals
3. **Supply Planning**: Intelligent component ordering based on forecasts and inventory
4. **Event System**: Internal campaigns and external market events
5. **Assembly Simulation**: Component delivery delays and watch assembly with capacity constraints
6. **Distribution Logic**: Regional demand-based distribution to retailers
7. **Customer Behavior**: Purchase probability based on preferences, budget, and brand awareness
8. **Performance Tracking**: GMROI, fill rate, forecast accuracy, and other KPIs
9. **Research Logging**: Comprehensive reporting and baseline comparisons

## Simulation Flow

The simulation follows a linear flow as designed:

1. **Initialization**: Generate all entities
2. **Forecasting**: Predict demand using ML models
3. **Supply Planning**: Generate component orders
4. **Event Management**: Apply campaigns and market events
5. **Assembly**: Process deliveries and assemble watches
6. **Distribution**: Allocate watches to retailers
7. **Customer Simulation**: Process purchases and returns
8. **Model Updates**: Train AI models with new data
9. **KPI Tracking**: Log performance metrics

## Output

The simulation provides:
- Real-time progress updates for each timestep
- KPI tracking (GMROI, fill rate, conversion rate, forecast accuracy)
- Final comprehensive report with:
  - Model performance metrics
  - Average and final KPIs
  - Revenue and cost analysis
  - Comparison against baselines (if set)

## Notes

- Pygame rendering is prepared for future implementation
- Logging can be controlled via the --debug flag
- All random processes use seeds for reproducibility
- The simulation is designed to be modular and extensible
 No newline at end of file

requirements.txt

0 → 100644
+6 −0
Original line number Diff line number Diff line
numpy>=1.21.0
pandas>=1.3.0
pygame>=2.0.0
scikit-learn>=1.0.0
xgboost>=1.5.0
 No newline at end of file

setup.py

0 → 100644
+16 −0
Original line number Diff line number Diff line
from setuptools import setup, find_packages

setup(
    name="supply-chain-sim",
    version="0.1.0",
    packages=find_packages(),
    install_requires=[
        "numpy>=1.21.0",
        "pandas>=1.3.0",
        "pygame>=2.0.0",
        "scikit-learn>=1.0.0",
        "xgboost>=1.5.0",
    ],
    python_requires=">=3.8",
)
 No newline at end of file
+29 −0
Original line number Diff line number Diff line
"""Supply Chain Simulation Package for Watch Industry."""

from .simulation import SupplyChainSimulation, run_oneshot_simulation
from .synthetic_setup import SyntheticEntitySetup
from .forecasting import Forecasting
from .supply_order import SupplyOrderLogic
from .event_injection import EventInjection
from .assembly import ComponentFlowAssembly
from .distribution import RetailDistribution
from .customer_behavior import CustomerBehavior
from .model_update import ModelUpdate
from .research_logging import ResearchLogging

__version__ = "0.1.0"

__all__ = [
    "SupplyChainSimulation",
    "run_oneshot_simulation",
    "SyntheticEntitySetup",
    "Forecasting",
    "SupplyOrderLogic",
    "EventInjection",
    "ComponentFlowAssembly",
    "RetailDistribution",
    "CustomerBehavior",
    "ModelUpdate",
    "ResearchLogging"
]
 No newline at end of file