Path: blob/main/notebooks/03/03-recharging-electric-vehicle.ipynb
663 views
3.3 Recharging strategy for an electric vehicle
Whether it is to visit family, take a sightseeing tour or call on business associates, planning a road trip is a familiar and routine task. Here we consider a road trip on a pre-determined route for which need to plan rest and recharging stops. This example demonstrates use of Pyomo disjunctions to model the decisions on where to stop.
Preamble: Install Pyomo and a solver
The following cell sets and verifies a global SOLVER for the notebook. If run on Google Colab, the cell installs Pyomo and the HiGHS solver, while, if run elsewhere, it assumes Pyomo and HiGHS have been previously installed. It then sets to use HiGHS as solver via the appsi module and a test is performed to verify that it is available. The solver interface is stored in a global object SOLVER for later use.
Problem Statement
Given the current location , battery charge , and planning horizon , a driver needs to plan ahead when to rest and when to charge his electric vehicle. Data are provided for the location and charging rate available at each charging station. The distances to the charging stations are measured relative to an arbitrary location. The objective is to drive from location to location in as little time as possible, subject to the following constraints:
The maximum charge is kW.
To allow for unforeseen events, the state of charge should never drop below of the maximum battery capacity, so kW.
For comfort, no more than hours should pass between stops, and that a rest stop should last at least minutes.
Any stop includes a minutes of "lost time".
For the first model we make several simplifying assumptions that can be relaxed as a later time.
Travel is carried out at a constant speed km per hour and a constant discharge rate kWh/km
Batteries recharge at a constant rate determined by the charging station.
Only consider stopping at the recharging stations and always recharging while resting.
Modeling
The problem statement identifies four state variables.
the current battery charge
the elapsed time since the last rest stop
elapsed time since the start of the trip
the current location
The charging stations are located at positions for and have charging rates per time unit . The arrival time at charging station is given by
where the script refers to departure from the prior location. At each charging location there is a decision to make about whether to stop, rest, and recharge. If the decision is positive, then
which account for the battery charge, the lost time and time required for battery charging, and allows for a minimum rest time. On the other hand, if a decision is made to skip the charging and rest opportunity, then
The latter sets of constraints have an exclusive-or relationship. That is, either one or the other of the constraint sets hold, but not both.
Charging Station Information
The following code cell generates 20 random charging station with heterogeneous location and charging rates.
Route Information
Car Information
We now specify the car information as described in the problem statement. Note that we specify them as global variables so that they can be used in the model.
Pyomo Model
We can implement the problem described above as a Pyomo model and solve it. The solution is presented in a table that shows the location, the arrival time, the departure time, the battery charge at arrival and at departure, and the length of the stop.
The following code visualizes the optimal EV charging plan, showing when to stop and how much to recharge the battery.