Skip to content

Uses machine learning optimization techniques and the Google Maps API to find the ideal location for new electric vehicle charging infrastructure

Notifications You must be signed in to change notification settings

theRocket/evchargestation-optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EV Charge Station Optimizer

Purpose and Motivation

This project uses machine learning optimization techniques and the Google Maps API to find the ideal location for new electric vehicle charging infrastructure.

According to government data cited in a late Dec 2023 article in the WSJ, the U.S. has around 159,000 public charging ports now at 60,000 locations. The estimated supply needed to meet EV demand in the next 6 years varies from a tripling to a 10x increase:

President Biden aims to have 500,000 public chargers in the ground by 2030. Consulting firm McKinsey estimates that around 1.5 million public chargers would be needed by then if half of car sales are electric.

Also cited in this article are the difficulties EV charging companies have remaining economically viable during this classic "chicken-and-egg" problem of supplying the EV charging infrastructure needed in advance of demand for EVs in order to reduce range anxiety and consumers' reluctance to commit to an EV purchase. However, the capital investment required to build out charging locations before consumers are buying electricity places a heavy burden on the for-profit EVSE enterprise. Placing this infrastructure in strategically optimized locations could help them acheive return on their investment in the near term.

Sample Script Run

An example in src/main.py after loading lat/long values from a .csv file in Google Cloud Storage into a Pandas dataframe

    # get csv data from Cloud Storage
    my_storage = GCSClient()
    my_data_inmem = my_storage.download_blob_into_memory('wipeout.csv')
    csvStringIO = BytesIO(my_data_inmem)
    df = pd.read_csv(csvStringIO, sep=",")
    get_a_loc=df[['ERS_LATITUDE','ERS_LONGITUDE']].iloc[0]

    # do map stuff
    my_gmap_client = GMapClient()
    search_loc = {'latitude': get_a_loc.ERS_LATITUDE, 'longitude': get_a_loc.ERS_LONGITUDE} # from above
    radius = 10.0
    print(f'Searching nearest EV charging stations in {str(radius)} km radius from {search_loc}')
    distance = my_gmap_client.find_closest_station(radius, search_loc) # could accept default lat/lng from init
    print(f'Distance to nearest station: {str(distance/1000)} km')

The raw data elements (source described below) include: VEHICLE YEAR MAKE MODEL, TOW FROM LATITUDE LONGITUDE, NEAREST CITY The first sample data element is:

['2018 NISSAN LEAF', 47.61453 -117.42536, 'Spokane WA']

The next-nearest station search algorithm runs in main.py looking in 10km radius and outputs the following:

❯ poetry run python src/main.py
Searching nearest EV charging stations in 10.0 km radius from {'latitude': 47.61453, 'longitude': -117.42536}
Distance to nearest station (ID: ChIJAQBMiKYYnlQREbjQNFL7cVI): 14.441 km
Place Types: ['electric_vehicle_charging_station', 'point_of_interest', 'establishment']
EV Charging Station: EV Connect Charging Station: 2904 E Sprague Ave, Spokane, WA 99202, USA
connector_count: 2
connector_aggregation {
  type_: EV_CONNECTOR_TYPE_CCS_COMBO_1
  max_charge_rate_kw: 180
  count: 1
  available_count: 0
  out_of_service_count: 0
  availability_last_update_time {
    seconds: 1704335400
  }
}
connector_aggregation {
  type_: EV_CONNECTOR_TYPE_CHADEMO
  max_charge_rate_kw: 100
  count: 1
  available_count: 0
  out_of_service_count: 0
  availability_last_update_time {
    seconds: 1704335400
  }
}

Verifying this route directly by putting in the same LAT/LNG values and asking for directions to an "ev station":

Google Maps Spokane WA

We see that 14.441 km matches the web result of 9.0 mi. Note also it appears to be a public library (useful later for searching for alternate EV charging sites).

Google Maps Hive

Using the vehicle make and model, we will also determine the charge connector type and validate that against the nearby charging station available connector types, as provided in the Google Maps API response.

A 2018 Nissan Leaf in the example above does support the CHAdeMO connector. However 14.4 km may have been too far for this driver to reach on low charge. Incompatible connectors may be used to eliminate close range charging options.

Data Sources

Optimum EV Charging Infrastructure locations comes from several sources.

Points of Origin

The first task is to select the starting point from which to target a new nearest station.

This data was selected first, specifically targeting places where their customers have had to call for assistance due to an out-of-charge incident.

Since this data costs $200 per state and year of data, I have purchased this out-of-pocket and placed the files in a private bucket only my Google Cloud credentials can access.

An interactive map showing where electricity infrastructure is needed to accomodate full electrification of all vehicles by 2030.

This data was selected second since it has already been vetted for EV infrastructure needs in the long-term, and EV infrastructure is a long-term investment.

According to their FAQ:

Through a collaborative, anonymous, secure, and transparent process, EPRI worked with a number of analytical partners and data providers to collect both publicly available and proprietary data - such as vehicle registrations, trip data and driving patterns, vehicle efficiencies, electrification plans, and state and federal policy. This data was used in combination with projected EV adoption in different areas of the country to develop the eRoadMAP estimates.

This tool reflects a combination of both high-confidence data sources and simulations of expected adoption. As EPRI gathers more and more data, the confidence in the energy estimates at each hexagon will rise. It should also be noted that generally as one zooms in to smaller and smaller hexagons, the certainty will decrease as the data is reliant on the behavior of fewer vehicles rather than an aggregated number.

Using this tool with the sample above in Latah Valley near Spokane, WA:

eRoadmap Latah Valley

The near-term electricity supply recommended for this hexagon in light duty vehicles is 652 kWh per day. That is a full charge for 11 to 18 vehicles, depending on the type. We see the next nearest station from the out-of-charge event (red circle) is sited at a public library approx. 5 miles away (green circle).

Searching within this closer light orange area for a parking location suitable for public charging, we find only churches and a few small parks. Considering these types of locations will be useful in the next section.

Finding Optimum Destinations

Google Maps Places and Routes APIs

This API is used to route from an origin above to a nearest station and find the total driving distance via the best route (not linear distance or "as the crow flies"). If there is not one with a valid connection type for the stranded vehicle within 15 kilometers (parameter to be tuned), then one will be generated by the ML optimization routine.

Note, the Google Maps Places API provides the following data on the charging stations:

  ev_charge_options {
    connector_count: 2
    connector_aggregation {
      type_: EV_CONNECTOR_TYPE_J1772
      max_charge_rate_kw: 6.4800000190734863
      count: 2
      available_count: 2
      out_of_service_count: 0
      availability_last_update_time {
        seconds: 1702313400
      }
    }
  }

The available list of connector types is published in the google.maps.places.v1 API documentation.

The NREL data describe below also has this data as:

"ev_connector_types":["CHADEMO","J1772"]

This is important because, without a compatible connector or an adapter in the vehicle, the stranded driver cannot use this infrastructure to recharge their vehicle.

New EV Placement Location Types

Google API Place Types are referenced when searching for the ideal nearest next station. These were narrowed down primarily by capabilities for handle a higher volume of automobile traffic. We also want periodic slow periods where potential visitors seeking charging infrastructure would be welcome as customers or short-term guests (1-4 hours). Government sites are also selected since cities will be investing taxpayer dollars in setting an example for de-carbonizing infrastructure, and those investments must be made available to the public.

Automotive
['car_dealer', 'gas_station', 'parking', 'rest_stop']
Entertainment and Recreation
['casino', 'community_center', 'convention_center', 'cultural_center', 'event_venue', 'marina', 'movie_theater', 'visitor_center']
Lodging
['campground', 'extended_stay_hotel', 'hotel', 'lodging', 'motel', 'resort_hotel', 'rv_park']
Shopping
['auto_parts_store', 'book_store', 'department_store', 'electronics_store', 'furniture_store', 'grocery_store', 'hardware_store', 'home_improvement_store', 'shopping_mall', 'sporting_goods_store', 'supermarket']
Sports
['athletic_field', 'fitness_center', 'golf_course', 'gym', 'sports_club', 'sports_complex', 'stadium']
Transportation
['airport', 'ferry_terminal', 'light_rail_station', 'park_and_ride', 'truck_stop']
Other (Government | Education | Health & Wellness | Places of Worship)
['city_hall', 'courthouse', 'library', 'hospital', 'church']

Validation

The AFDC has an interactive map showing nearest stations along a route. This is also available via API so it can be referenced as a test validation for the results found above via Google Maps API.

Getting Started

Installation of Python Packages

Uses Poetry for dependency management (a good write-up to justify why I chose Poetry is on Medium here).

First install the required libraries (Poetry sets up its own virtualenv) then you can run a sample script to fetch some nearby places like so:

poetry install
poetry run python src/main.py

Tests can be run like so (note: API calls still not mocked, so requests count against billable limits):

poetry run pytest

Related Works

Leverages a D-Wave Quantum Annealer Uses a Binary Quadratic Model (BQM) hybrid solver to determine where to place new charging stations on a map based on locations of existing charging stations and points of interest (POI). 2 years old, 5 contributers all based in Vancouver, BC (likely D-Wave employees)

####ChargeUp A PhD in Economics presentation on optimizing locations of electric vehicle charging stations in the city of Toronto. 4 years old, website no longer function, very localized

PricewaterhouseCoopers (PwC)

America’s coast-to-coast EV-charging network: Where – and how – it could roll out Provides investment analysis on what types of businesses would benefit by adding EV charging stations, including:

  • Fueling stations
  • Rest stops
  • Hotels
  • Retailers (malls)
  • Office buildings

This location type can be cross-referenced to the Google API Place Types when searching for the ideal nearest next station in our algorithm as described above.

About

Uses machine learning optimization techniques and the Google Maps API to find the ideal location for new electric vehicle charging infrastructure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages