ECS Mini Project | VIT Chennai | April 2026
This project simulates an AI-controlled Hybrid Energy Storage System (HESS) for regenerative braking in electric vehicles. A Random Forest ML classifier decides in real time how to split recovered braking power between a lithium-ion battery and a supercapacitor, optimising energy recovery while protecting battery health.
In conventional vehicles, all kinetic energy is wasted as heat during braking. EVs can recover this energy — but smart storage management is critical. This project solves that using machine learning.
| Metric | Value |
|---|---|
| Total energy recovered | 1,304 Wh |
| Braking events handled | 4,363 |
| ML decision accuracy | ~95% (5-fold CV) |
| Battery cycles accumulated | 0.175 |
| Simulation duration | 20 minutes |
| Training samples | 27,615 |
%%{init: {
"theme": "base",
"themeVariables": {
"fontSize": "20px"
},
"flowchart": {
"nodeSpacing": 120,
"rankSpacing": 100,
"curve": "basis"
}
}}%%
flowchart LR
A["Drive Cycle"]
--> B["Motor Gen"]
B --> C["DC-DC Conv"]
C --> D{"Power Split"}
D --> E["Battery"]
D --> F["Supercap"]
E --> G["ML Agent"]
F --> G
G --> D
style A fill:#065A82,color:#ffffff,stroke:#ffffff,stroke-width:2px
style B fill:#065A82,color:#ffffff,stroke:#ffffff,stroke-width:2px
style C fill:#065A82,color:#ffffff,stroke:#ffffff,stroke-width:2px
style D fill:#1C7293,color:#ffffff,stroke:#ffffff,stroke-width:2px
style E fill:#0F6E56,color:#ffffff,stroke:#ffffff,stroke-width:2px
style F fill:#534AB7,color:#ffffff,stroke:#ffffff,stroke-width:2px
style G fill:#BA7517,color:#ffffff,stroke:#ffffff,stroke-width:2px
| Component | Description |
|---|---|
| Drive Cycle | Generates vehicle driving conditions |
| Motor Generator | Simulates regenerative braking |
| DC-DC Converter | Controls energy conversion |
| Power Split | Distributes recovered energy |
| Battery Model | Thevenin battery model |
| Supercap Model | RC supercapacitor model |
| ML Agent | Random Forest optimization agent |
| File | Description |
|---|---|
storage_model.py |
Battery (Thevenin) + Supercapacitor (RC) models with SoC tracking |
drive_cycle.py |
Vehicle dynamics + synthetic drive cycle generator |
train_agent.py |
Dataset generation + Random Forest ML training pipeline |
simulate.py |
Full closed-loop simulation + 6-panel results dashboard |
cosim_controller.py |
Python to Simulink bridge via MATLAB Engine API |
regen_model.slx |
MATLAB Simulink power electronics model |
requirements.txt |
Python dependencies |
git clone https://github.com/tanisha-ahl/regen-braking-hess.git cd regen-braking-hess
pip install -r requirements.txt
python simulate.py
This will automatically:
- Generate a labelled training dataset from drive cycle simulations
- Train the Random Forest classifier and save it to model/
- Run a 20-minute closed-loop simulation (ML agent vs threshold baseline)
- Print a results summary in the terminal
- Save a 6-panel dashboard to results/simulation_dashboard.png
python train_agent.py
python cosim_controller.py
The Random Forest classifier makes real-time power split decisions at every braking event:
| Class | Decision | Split Ratio | Trigger Condition |
|---|---|---|---|
| 0 | Supercap-heavy | 10% battery / 90% SC | Jerk > 1.5 m/s3, OR battery SoC > 85% |
| 1 | Balanced | 50% / 50% | Normal SoC range, moderate braking |
| 2 | Battery-heavy | 80% battery / 20% SC | Supercap SoC > 75% OR supercap SoC < 25% |
| Feature | Importance | Description |
|---|---|---|
| jerk | 38% | Rate of change of acceleration |
| soc_supercap | 22% | Supercapacitor state of charge |
| bat_cycles | 18% | Accumulated battery charge cycles |
| velocity_kmh | 12% | Vehicle speed |
| soc_battery | 10% | Battery state of charge |
- Supercap-heavy (Class 0): 2,613 events — 59.9%
- Balanced (Class 1): 838 events — 19.2%
- Battery-heavy (Class 2): 912 events — 20.9%
- Capacity: 50 Ah at 48V nominal (2.4 kWh)
- Series resistance R0: 0.01 ohm
- Polarisation branch: R1 = 0.005 ohm, C1 = 2000 F
- SoC range: 20% to 95%
- SoC tracking: Coulomb counting
- Capacitance: 3000 F
- Voltage range: 20V to 48V (usable ~100 Wh)
- ESR: 0.002 ohm
- SoC definition: (V - Vmin) / (Vmax - Vmin)
- Python 3.13 — simulation, ML training, visualisation
- scikit-learn — Random Forest classifier (200 trees, balanced class weights)
- MATLAB R2025a + Simulink — power electronics model
- MATLAB Engine API for Python — co-simulation bridge
- NumPy / Pandas — numerical computation and data handling
- Matplotlib — results dashboard and SoC plots
- Python 3.9 to 3.13
- pip install -r requirements.txt
- MATLAB R2022a or later with Simulink (only needed for cosim_controller.py)
- matlab.engine: pip install matlabengine==25.1
- Cao & Emadi (2012) — Battery/UltraCapacitor HESS for EVs. IEEE Trans. Power Electronics
- Song et al. (2014) — Energy Management Strategies for HESS. Applied Energy, Elsevier
- MathWorks — MATLAB Engine API for Python Documentation
MIT License — free to use, modify, and distribute with attribution. Copyright 2026 Tanisha Ahlawat