gggg03/Dynamic_Pricing_Optimization
0
P02 — Dynamic Pricing Optimization (RL)
Retail pricing simulation with Q-Learning (discrete prices) and DDPG (continuous prices, PyTorch), plus a live dashboard, competitor tracker, profitability comparison, and sensitivity analysis.
Project structure
Quick start (Windows)
cd "c:\Users\PMLS\Desktop\rl project"
pip install -r requirements.txt
run_project.batOr step by step:
pip install numpy flask torch
# Step 1 — test environment
python -c "from env_and_agents import RetailPricingEnv; e=RetailPricingEnv(42); print(e.reset().shape)"
# Full pipeline (Q-Learning + DDPG training, sensitivity, comparison, report)
python train_all.py
# Or run steps individually:
python step2_train_ql.py # Q-Learning training → ql_agent.npz
# (DDPG trains inside train_all.py — step 3)
python step5_compare.py # Comparison → comparison.json
python build_dash_data.py # Aggregate JSON → dash_data.json
python build_dashboard.py # Build dashboard HTML
python generate_report.py # Write REPORT.md
# Live dashboard (real env + trained agents — do NOT open as file://)
python dashboard_server.py
# Then open http://127.0.0.1:5050Assignment mapping
Environment details
- Discrete actions: 0.8, 0.9, 1.0, 1.1, 1.2 × base price ($100)
- Continuous (DDPG): multiplier ∈ [0.7, 1.5] via trained Actor network
- State: inventory, price, competitor price, hour, day, 7-day demand avg, product age %
- Reward: (revenue − COGS) − holding cost − stockout penalty − volatility penalty
- Demand: price-elastic vs competitor; peak-hour boost; weekend boost
DDPG architecture
Outputs
After python train_all.py:
Live dashboard strategies
The live simulator (python dashboard_server.py) supports:
fixed— always $100rule— heuristic rule agentql— trained Q-Learning agent (requiresql_agent.npz)ddpg— trained DDPG agent (requiresddpg_best.pth)random— random discrete action
