220 likes | 249 Views
Algoritmo di Routing Multi-Obiettivo di Veicoli Elettrici con vincoli di ricarica lungo il percorso Alessandro Betti, PhD alessandro.betti@i-em.eu Florence, 03 rd May2019. Data Science. OUTLINE. Introduction The Market of Electric Vehicles Model Requirements Model Architecture
E N D
Algoritmo di Routing Multi-Obiettivo di Veicoli Elettricicon vincoli di ricarica lungo il percorsoAlessandro Betti, PhDalessandro.betti@i-em.euFlorence, 03rd May2019 Data Science
OUTLINE • Introduction • The Market of Electric Vehicles • Model Requirements • Model Architecture • Data Collection • Geographical Data: Open Street Map and PythonPackages (OSMNx vs Pandana) • Charging Station Data: Open ChargeMapAPIs • Elevation Data: Google Maps, Bing Maps and NASA’s data • Feature Engineering and Data Imputation • Integrationofelevation data into the graph • Imputationofdrivingspeedforeach network edge • Computationof the Energy ConsumptionFunction and CSsintegration in the Network • Routing Algorithms and Speedup Techniques • Dijkstra’s algorithm • Multi-objectivesShortestPathSearch: the Pareto Set • Speed-Uptechniques: A*algorithm • Results for Tuscany Region • The impact ofbatteryconstraints on mobility • The robustnessof the model • Conclusions and Next Steps Alessandro Betti, PhD
Introduction: the market ofelectricvehicles • Leading countries contributing to electric: • Norway (Europe), about one half of vehicle sales in 2018 is electric • China (Asia): over 1 million of new EVs hitting the roads in 2018 • China also leads the world for number of charging stations, a significant part is FAST • By 2030, EVs could represent almost 20% of vehicles on the road worldwide, and 35% in Europe Alessandro Betti, PhD
Introduction: ModelRequirements • Build a smart routing algorithm that suggests the optimal route for the EV • Minimize travel time dt: driving time + charging time • Respect the SOC battery’s constraints (never runs out of charge) • Consider loss and gain of charge along the route • Therefore solve a multi-objective problem optimizing dt and SOC, and returning a set of optimal solutions Alessandro Betti, PhD
Introduction: ModelArchitecture FEATURE ENGINEERING DATA COLLECTION EV Energy Consumption Calculation DATA PRE-PROCESSING OSM Data Map creation Elevation Data MODEL PROCESSING OUTPUT Multi-Objective Shortest Path Algorithm Charging Stations Optimal Routes for EV (Pareto Set of optimal solutions) Alessandro Betti, PhD
Geographical Data: Open Street Map • Geographical Data are necessary to build the street network • They may be gathered from the Open Street Map (OSM) sources, a collaborative crowdsourced project to create a free editable map of the world (https://www.openstreetmap.org) • By means of OSM, the following data may be collected and are necessary for routing algorithms: • Location of network nodes, such as crossroads and sharp bends • Length between two adjacent nodes • Driving speed between two adjacent nodes • The type of the street between two adjacent nodes Alessandro Betti, PhD
Geographical Data: Pandasfor Network Analysis (Pandana) • Get Bounding Box for geographical area from: • https://boundingbox.klokantech.com/ • https://www.mapdevelopers.com/geocode_bounding_box.php • Create a graph network composed of nodes and edges by means of the Overpass API of OSM • nodes_df, edges_df= osm.network_from_bbox(lat_min= bbox[0], lng_min= bbox[1], lat_max= bbox[2], lng_max= bbox[3], network_type= 'drive') • After some processing and merging nodes and edges dataframes, following dataframe is obtained: max speed and highway type are present, but … • Integration of elevation data in the network and graph conversion to a dict of dicts are not straightforward (no built-in methods) • Plotting of the network should exploit the urbanaccess package, by means of nodes and edges dataframes returned by Pandana method • import urbanaccess as ua • fig, ax= ua.plot.plot_net(nodes= nodes_df, edges= edges_df, ...) Alessandro Betti, PhD • Box around Friuli Venezia Giulia
Geographical Data: retrieve and visualize OSM network withOSMnx • It allows to download spatial geometries and costruct, project, visualize and analyze street networks from OSM’s APIs • Different types of network may be retrieved as a NetworkX graph (drivable, walkable, bikeable) • Friuli Venezia Giulia • import osmnx as ox • place_name = 'Friuli Venezia Giulia, Italy' • graph = ox.graph_from_place(place_name, network_type = 'drive') • Easy conversion to geopandasdfs: • nodes, edges = ox.graph_to_gdfs(graph) • Pisa • It provides methods for plotting the network (ox.plot_graph, ox.plot_graph_folium) • Easy conversion to a dict of dicts(keys are starting nodes and values are neighbourhood) • It includes maxspeed and highway type as edges attributes, and integration of elevation as node attribute is easy • Easy integration of new items as edge attributes in the graph(e.g. driving time) nx.to_dict_of_dicts(graph) • for i, v, data in graph.edges(data= True): • data['dt'] = (float(data['length'])/ (1000* float(data['maxspeed'])))*60 # driving time (minutes) Alessandro Betti, PhD
Charging Station Data: Open ChargeMapAPIs • Free web service which allows to query CS locations by means of API calls • Open charge Map API available at: https://openchargemap.org/site/develop/api • API call for retrieve json data for Italy: https://api.openchargemap.io/v3/poi/?output=json&countrycode=IT • After some processing a Pandas df may be saved in a csv file containing the features: • Geographical cooordinates • Power supplied (KW) • Number of plugs • Name of energy provider • Price per time unit • ITALY Alessandro Betti, PhD
Charging Station Data: ChargingStationsvisualizationwithFolium • Four different type of chargers: Private (5-7 kW), Quick (22 kW), Fast (50 kW), Ultra Fast (> 100 kW) • Almost 2 hundred charging points in Tuscany, easily visualizable by means of a Folium Heatmap • Key functions: folium.Map, folium.CircleMarker, add_children, folium.plugins.HeatMap • QUICK • ITALY Alessandro Betti, PhD
Elevations Data: Google Maps, Bing Maps and NASA data Alessandro Betti, PhD
Feature Engineering and Data Imputation: integration of Elevation data • OSMnx package provide effective methods for retrieving elevation data from Google Maps API and insert them straight in the network • By converting nodes and edges to geodataframe, we may verify this: • api_key = ‘************************' #'Insert your API key here' • graph = ox.elevation.add_node_elevations(graph, api_key=api_key) # get elevation and add to the node • graph = ox.elevation.add_edge_grades(graph, add_absolute=False) # get directed grade for each edge and add to the edge • nodes, edges = ox.graph_to_gdfs(graph) Alessandro Betti, PhD
Feature Engineering and Data Imputation: imputation of driving speed • Since a graph with static weights is built, we assume to use the max speed attribute as default speed for each network edge, so the driving time for each road may be computed • However this info is missing for more than 80% edges, so imputation for missing data is necessary • Since the highway attribute is always present, it may be used to group records according to this key, imputing edges with missing maxspeed • matplotlib.pyplot.bar • Example for Friuli Venezia Giulia • matplotlib.pyplot.barh • Imputation has been done by using info from current Italian Traffic Regulations • An alternative solution is exploiting speed distributions available for each highway type Alessandro Betti, PhD
Feature Engineering: Computation of the Energy Consumption Function • An Energy Consumption Function has been defined in order to evaluate how SOC changes along the path: • Energy consumption is evaluated at each section of road when any of the variables change (if E > 0, then energy is consumed): Inertial Force (=0 since a=0 as Ip) Aerodynamic Drag Ftot = Frr + Fad + Fhc + Fi Rolling Resistance Hill Climbing Force Road length Vehicle tank-to-wheels efficiency • Convert the graph in a dict of dicts (networkx.to_dict_of_dicts) and add driving time and energy consumption into the graphasedgeweights, removing the other attributes: Consumption Travel time Alessandro Betti, PhD
Feature Engineering: Integration of Charging Stations in the network • Each CS is modelled as multiple “fake” network nodes (let’s say 4, up to 40 min recharge) corresponding to different charging time • Each charging time slot is a multiple of 10 minutes • closest_node, cs_distance = ox.utils.get_nearest_node(graph, (float(cs_area.lat[i]),float(cs_area.lon[i])), return_dist= True) Alessandro Betti, PhD
RoutingAlgorithms: Dijkstra’s Algorithm • The goal is developing a routing algorithm that returns a route with lowest travel time (Shortest Path problem) • Dijkstra’s algorithm solves the single-pair, as well as the single source (or destination) shortest path problems, with the precondition of not-negative edge weights (solution in polynomial time) • Dijkstra’s algorithm is not applicable to EV routing, since we are dealing a Constrained Shortest Path problem with an energy consumption function E R and battery constraints B= [0, M] • Therefore a Multi-Objective Optimization problem must be solved, monitoring not only travel time but also the SOC for each edge Correct distance in the shortest path from s to v Pointer to the previous node in the shortest path from s to v Alessandro Betti, PhD
RoutingAlgorithms: Multi-ObjectiveShortestPathSearch Key functions: folium.Map, folium.Marker, add_children, folium.PolyLine • EV Route Planning: find the shortest path P= (s= v1, v2, …, vk=t) ϵG from s to t which is feasible, i.e. b(P,i) ϵ B for all 1 ≤ i ≤ k • A Multi-objective optimization problem can be solved by introducing a Pareto set: a solution is called Pareto-optimal if there are no other solutions better with respect to every objective (travel time dt and SOC b) • As in the case of Dijkstra, the operations of label settling and edge relaxations are present • Since the main objective is minimizing travel time, this objective is used as primary criterion to order label: labels are settled in increasing order of dt Alessandro Betti, PhD
Speedup Techniques: A* Algorithm • Multi-Objective problem is NP-complete: the computational time increases exponentially with the size of the graph • A* is a best-first search: it classifies nodes according to a Heuristic estimation of the cost of the best path passing for that node and visit node according to this estimation • Cost is composed by two terms: estimate of the cost from n to the goal t • matplotlib.pyplot.semilogy • matplotlib.pyplot.fill_between f(n)= g(n)+h(n) the actual cost from source s to current node n 102!! • In our case g is the travel time from s to n and h the estimated travel time from n to t • A* may decrease computing time up to almost two orders of magnitudes for the largest path considered in Tuscany Alessandro Betti, PhD
ResultsforTuscanyRegion: the impact ofbatteryconstraints on mobility • Initial SOC= 100% • Initial SOC= 50% • Initial SOC= 30% • If the trip is longer, the detour from the nominal path (i.e. the one suggested for conventional path or EVs with initial SOC of 100%) is more evident (see differences between 100 % and 30%) Alessandro Betti, PhD
Results for Tuscany Region: the robustness of the model • Nominal Case • Accident • Road works • Our algorithm shows a strong capability to adapt also on external factors, such as accidents or road works in progress Alessandro Betti, PhD
Conclusion and Next Steps • A Multi-Objective Shortest Path Search Algorithm has been developed delivering the optimal path for EVs, both optimizing travel time and energy consumption and accounting for battery constraints • A Pareto set of solutions is delivered, suggesting also where to recharge and the charging time required at the CSs • Unlike traditional solutions which divide the whole path in smaller parts and optimize them separately, the proposed algorithm operates on the whole path and returns the global optimal solution • The adoption of the Python packages OSMnx for drive network retrieval and manipulation, together with the Folium package for map visualization, allows an effective and fast design of the model • Next steps include: • the extension of the geographical area of the routing algorithm to the whole Italy • a further improvement of the computing time by means of speedup techniques • a better modeling of CSs, considering continuous charging times instead of discrete values • integration of traffic data Alessandro Betti, PhD
Thank you!Acknowledgements: Simone Mattera (Master in Big Data Analytics, Pisa)Prof. MircoNanni (CNR, Pisa) • www.i-em.eu Alessandro Betti, PhD alessandro.betti@i-em.eu Alessandro Betti, PhD