Optimizing the placement of electric vehicle (EV) charging stations is a challenging problem. The goal is to find the optimal locations for a given number of charging stations to maximize the number of EVs that can be served. To solve this problem, we can use D-Wave's quantum annealer to find the optimal locations for the charging stations using a quadratic unconstrained binary optimization (QUBO) formulation.
This repository contains the code for solving the EV charging station placement problem using simulated annealing and genetic algorithms and is based on the ev-charger-placement
example by D-Wave [1].
The problem of placing electric vehicle (EV) charging stations can be formulated as a Quadratic Unconstrained Binary Optimization (QUBO) problem. Given a set of potential locations for the charging stations, we aim to identify a subset of locations that maximizes the coverage of points of interest (POIs) while also maximizing the distance between charging stations to avoid redundancy.
First, we define the distance function
where
Let
The objective function we want to minimize is defined as follows [2]:
where:
-
$p$ denotes points of interest (POIs), -
$e$ denotes existing charging stations, -
$c_i$ is the coordinate of the$i$ -th potential new charging station, -
$x_i$ is a binary variable that is 1 if a new charger is placed at$c_i$ , and 0 otherwise, -
$m$ is the desired number of charging stations, -
$\lambda_i$ are the Lagrange multipliers.
The scoring metric used to evaluate the quality of the solution is defined as:
The goal is to maximize the score by placing the charging stations in optimal locations, while ensuring that new and existing charging stations are not placed too close to each other.
The code is organized as follows:
│ .gitignore
│ annealing.ipynb
│ genetic.ipynb
│ README.md
│ requirements.txt
│
├───src
│ │ evcp.py
│ │ solvers.py
│ │ utils.py
│ └───__init__.py
│
└───readme_imgs
│ genetic_solution.png
│ map.png
│ old_grid.png
└───solution_grid.png
The src
directory contains the following Python files:
evcp.py
: Contains the implementation of the EV Charging Problem (EVCP) class, which defines the grid, points of interest, and charging stations.solvers.py
: Contains the implementation of the simulated annealing and genetic algorithm solvers.utils.py
: Contains utility functions.
The annealing.ipynb
and genetic.ipynb
notebooks contain the code for solving the EVCP using simulated annealing and genetic algorithms, respectively.
To run the code, follow these steps:
- Create a virtual environment using
python -m venv venv
and activate it. - Install the required packages using
pip install -r requirements.txt
. - Run the
annealing.ipynb
orgenetic.ipynb
notebook to solve the EVCP using simulated/quantum annealing or genetic algorithms. - Test different parameters and configurations.
By default, when initializing the QuantumAnnealing
class, the sampler used is D-Wave's SimulatedAnnealingSampler
. However, you can change the sampler to use D-Wave's quantum hybrid solver by setting sampler=LeapHybridSampler()
during the initialization of the QuantumAnnealing
class.
Here is an example of a grid with points of interest (POIs) and existing charging stations:
Here is an example of the solution obtained using the genetic algorithm:
Here is the final grid with the optimal charging station locations using quantum annealing:
- [1] D-Wave (2021). EV Charger Placement. https://github.com/dwave-examples/ev-charger-placement.
- [2] Aman Chandra, Jitesh Lalwani, and Babita Jajodia (2022). Towards an Optimal Hybrid Algorithm for EV Charging Stations Placement using Quantum Annealing and Genetic Algorithms. arXiv: 2111.01622 [quant-ph].