BatterySwapAI — Battery Remaining-Useful-Life & Swap Scheduling
Predict when field batteries will wear out, and plan their replacement swaps at the lowest possible operational cost.
What this project does
Battery-powered devices are deployed across many rooms and buildings, and their batteries slowly degrade. Swapping a battery too late risks an outage; swapping it too early throws away useful life and wastes a technician's trip. Getting the timing right across a whole fleet is a hard planning problem.
This project solves it in two stages:
- Remaining-Useful-Life (RUL) forecasting. A survival model reads each battery's voltage and temperature history and estimates how much longer it will keep working.
- Swap scheduling. A constraint-optimisation planner turns those forecasts into a day-by-day work order for technicians, weighing the cost of early vs. late replacements against travel time, room and building changes, and daily/weekly working-hour limits.
The result is a schedule that replaces the right batteries on the right days while keeping technician workload and travel low.
How it works
| Component | Role |
|---|---|
features.py |
Turns raw voltage/temperature series into battery-degradation features. |
forecast.py |
Survival model that predicts each battery's remaining useful life. |
optimisation.py |
Constraint-programming (CP-SAT) planner that schedules the swaps. |
simulate.py |
Cost simulator used to refine the schedule. |
batteryswap_example/train.py |
Trains the model and saves the planner. |
script.py |
Loads the trained planner and produces a swap plan for a dataset. |
The trained planner ships in batteryswap_example/planners/ (stored with Git LFS).
Getting started
The project runs in Docker, which pins the exact runtime environment.
# Build the image
docker build -t batteryswapai .
# Generate swap plans and score them on the local dataset
docker run --rm -v ./dataset:/tmp/data batteryswapai \
bash -c "/app/env/bin/python3 script.py && /app/env/bin/python3 -m batteryswap_public.metric"
Place your data under dataset/ — a train/ folder containing the device
metadata, end-of-life times, and scenario definitions.
Background
Developed by the rule mgt zero team (solution by Benjamin Kjøpstad Kofoed) for the BatterySwapAI 2026 Challenge.
License
Released under the MIT License.