Great
Weekend Build: Optimising Singapore’s EV Network with K-Means Clustering
The Singapore Green Plan 2030 has a massive target: 60,000 EV charging points by 2030. That is a lot of chargers, and placing them isn’t as simple as throwing a dart at a map. You need to balance grid load, accessibility, and coverage.
This weekend, instead of just reading about it, I decided to build a tool to solve it.
Introducing VoltVantage, a web-based simulation that uses K-Means Clustering to determine the optimal placement of EV charging stations across Singapore’s existing carparks.
The Problem: The Charging Station Placement Problem (EVCPP)
In computer science terms, placing these chargers is an optimisation problem. We have a set of constraints (boundaries, available carparks) and a goal (maximum coverage with minimum overlap).
I grabbed the official dataset of Singapore’s carparks (carparks.json) and the country’s geospatial boundaries (singapore-boundary.json) to create a realistic testing ground. The goal? To see if an algorithm could mathematically determine the most efficient spots to serve the most people.
Under the Hood: The Tech Stack
I built this using a modern, lightweight stack designed for speed and interactivity:
- Frontend: React / Next.js
- Visualisation:
react-leafletfor the interactive map layer. - Geospatial Analysis:
Turf.js. This was the workhorse for the spatial logic. - Data: Real-world HDB/URA carpark data.
The “AI” Sauce: K-Means Clustering 🧠
The coolest part of VoltVantage is the logic in EVPlanner.tsx. Instead of randomly guessing locations, I implemented K-Means Clustering.
For those unfamiliar, K-Means is an unsupervised machine learning algorithm commonly used for grouping data. Here is how VoltVantage applies it to infrastructure:
- Data Ingestion: It takes the coordinates of thousands of carparks across Singapore.
- Clustering: The algorithm groups these carparks into k distinct clusters based on their geographical proximity.
- Centroid Calculation: For each cluster, it calculates the “centroid”, the geometric centre of gravity.
- Optimisation: This centroid becomes the proposed location for a charging station.
By doing this, the system ensures that the charging station is placed in the “middle” of a high-density area, minimising the average distance any driver in that cluster has to travel to get a charge.
The Result
Watching the simulation run is satisfying. You start with a raw map of carparks, and the algorithm instantly brings order to the chaos. It highlights natural hotspots of vehicle density and places markers exactly where they are needed most.
It’s a functional proof-of-concept that infrastructure planning doesn’t have to be based on gut feeling, it can be solved with geometry and code.
Why I Built It
Coming off the back of my internship at Accenture (H&PS) and the recent Kaggle competition, I’ve been obsessed with how data can influence public infrastructure. VoltVantage was a way to combine my frontend skills with the data science concepts I learned in university.
Plus, it was a great excuse to finally play around with Turf.js.
The code is still a weekend prototype, but the potential is there. If we’re going to hit that 2030 target, we’re going to need tools like this to make sure every charger counts.
Data beats opinion.
- W. Edwards Deming
[· ]