Optimizing fleet utilization with Amazon Location Service and HERE Technologies
AWS Architecture BlogOptimizing fleet utilization with Amazon Location Service and HERE Technologiesby Mahesh Geeniga, Aaron Miller, Karthik Manjunatha, and Shane Jordan | on05 APR 2023| inAmazon DynamoDB,Amazon Location,Amazon Simple Storage Service (S3),Architecture,AWS Cloud Development Kit,AWS Lambda,Technical How-to|Permalink|ShareThe fleet management market is expected to grow at a Compound Annual Growth Rate (CAGR) of 15.5 percent—from 25.5 billion US dollars in 2022 to USD 52.4 billion in 2027. Optimizing how your organization uses its vehicle fleet is important for logistics and service providers such as last mile, middle mile, and field services.In this post, we demonstrate how to build and run a solution for many-to-many vehicle routing usingHERE Tour PlanningandAmazon Location Service.HERE Technologiesis adata providerfor Amazon Location Service and provides it with map rendering, geocoding, search, and routing. HERE Tour Planning expands on functionality such as geocoding, basic routing, and matrix routing to consider parameters such as time windows, job requirements or priorities, vehicle capabilities, range, and traffic information. They also support immediate re-planning when conditions change.The architecture described in this post can help you optimize your fleets for delivering shipments, such as perishable items on pallets, from a central distribution center to multiple retail locations. The architecture uses theAWS Cloud Development Kit(AWS CDK) to help you provision and version control your infrastructure. The architecture also uses Event Driven Architecture (EDA) based onAWS LambdaandAmazon DynamoDB. It usesAmazon Simple Storage Service(Amazon S3) and DynamoDB to store the artifacts generated and integrates with Amazon Location Service to plot the routes visually on a map for each delivery driver.Solution overviewThis post will help you:Configure the many-to-many vehicle routing architecture using HERE Tour Planning and Amazon Location ServiceSubmit a HERE Tour Planning problemGenerate an optimized solution fileRun aReactapp that:Generates a list of routes for each vehicle in the fleetAllows drivers to select and view routes in detailThe following diagram outlines how the architecture works.Figure 1. Many-to-many vehicle routing architecture using HERE Tour Planning and Amazon Location ServiceLet’s explore the steps in the diagram.The fleet operator uploads the tour requirements file to an Amazon S3 bucket.The upload invokes a Lambda function to process the new Tour Request. If the HERE API key is present, it calls the HERE Tour Planning API.The HERE Tour Planning API calculates the solution to the routing problem.The driver uses the React app to select a vehicle, which requests a route.The invoked Lambda function uses Amazon Location Service to calculate the route and render it in the React app.PrerequisitesThis walkthrough requires the following installations and resources:Have anAWS accountInstall theAWS Amplify CLI (command-line interface)Install theAWS CDK CLIInstall theAWS CLIConfigure and authenticate the AWS CLI to interact with your AWS account.Have your preferred integrated development environment (IDE), such asVisual Studio CodeHave GitHub repository accessgit clone https://github.com/aws-samples/aws-here-optimize-fleet-utilizationHave a HERE API Key (optional)This is needed to invoke the HERE Tour Planning API for generating solutions to new routing problems.The GitHub sample repository includes a problem and pre-solved solution file, so you don’t need to acquire a HERE API key to learn about these offerings.To acquire an API key, create a free account on theHERE Platform, then follow the instructions in theHERE Tour Planning documentationto create your API key.There can be additional charges based on API key use. For more details, see the HERE Tour Planning section withinHERE service rates.WalkthroughProvision the infrastructureThe architecture uses NPM node modules. Run the following commands to install the dependencies:# AWS Lambda function dependenciescd lib/lambda/calculate-routenpm install# Sample Frontend application dependenciescd frontend/here-driver-appnpm installIf you have never used AWS CDK in your AWS account, you must firstbootstrapthe solution, which creates Amazon S3 buckets and metadata to support AWS CDK operations.Note:Architectural components described in this article are covered under AWS Free Tier and HERE Free monthly usage, but additional charges can occur based on usage beyond the Free Tier limits. We recommend following theCleanupinstructions after completing the walkthrough.From the root of the repository, run the following command to generate the needed infrastructure:cdk bootstrapOutput similar to the following indicates that you successfully bootstrapped the AWS account with what AWS CDK requires.Figure 2. Successful bootstrap of AWS account with AWS CDK requirementsDeploy the infrastructure for this solution by running the following command. This provisions much of the infrastructure required for this solution such as DynamoDB, Lambda functions, and Amazon S3 buckets:cdk deployNext, Amplify provisions the remaining resources to complete the architecture. Navigate to the folder for the frontend by running the following command:cd frontend/here-driver-appRun the following series of Amplify commands to create the remaining resources,Amazon API Gateway,Amazon Cognito, and Amazon Location Service. For additional details, seeClone sample Amplify project.To accept the defaults, run the following command:amplify initTo push the infrastructure out to the AWS account, run the following command:amplify pushTo publish the environment, run the following command:amplify publishCreate problem and generate architecture filesThe next step is to create the HERE Tour Planning problem file and submit it to the HERE Tour Planning API to solve.Note:You can either sign up for the HERE Developer program to receive an API key to test this solution live or use the problem and pre-solved solution provided in the/datafolder of the repository.Open the Amazon S3 bucket that the previous step created.Upload a problem file (in JSON format) to the bucket.An Amazon S3 event notification invokes a Lambda function that performs a synchronous call to the HERE Tour Planning API and generates vehicle routing problem solution file in JSON format.The Lambda function saves the solution file to the Amazon S3 bucket and additional details about the solution to a DynamoDB table.The delivery drivers can use the example React app to view the list of vehicles and the routes.Figure 3. Creating a problem file and submitting it to HERE Tour Planning APIFrontendThe next step is to run the React Frontend app to see the results. Access to the app and the API Gateway is secured with Amazon Cognito.To run the web application, run the following command:npm startA local web server runs on http://localhost:3000.To use the system, the user must authenticate. Amazon Cognito allows users to sign in or create a new account.After you authenticate, theHomescreen displays a list of available vehicles and routes.Figure 4. Available vehicles and routesChoose a vehicle to see the detail of the route. Each red marker is a stop.Figure 5. Vehicle route detailsCleanupTo avoid incurring future charges, delete all resources created.Run the following commands to delete the application in AWS Amplify. As an alternative, you can use theAmplify consoleto delete Amplify resources:cd frontend/here-driver-appamplify pullamplify deleteWith AWS CDK, run the following command to delete theAWS CloudFormationstack that was used to provision the resources. Note: You can leave the AWS CLI, Amplify CLI, and CDK CLI installed on your computer for future development:cdk destroyConclusionIn this post, using shipment delivery from a central distribution center use case, we’ve demonstrated how you can build your own serverless solution for optimizing middle and last mile operations. The solution uses multi-vehicle and multi-stop optimization services provided by HERE Tour Planning and Amazon Location Service to visualize the generated routes for each delivery vehicle driver. For additional details about HERE’s offerings on AWS Marketplace, seeAWS Marketplace: HERE Technologies.Mahesh GeenigaMahesh is a Senior Partner Solutions Architect at Amazon Web Services. He works with AWS strategic partners to build and promote innovative solutions leveraging AWS. He has over 20 years of experience with building robust software solutions to complex problems.Aaron MillerAaron Miller is a Business Solutions Architect at Here Technologies. He is focused on helping customers and partners leverage advanced geospatial capabilities to solve complex business challenges in the transportation and logistics space. In his free time, he enjoys flying aerobatics and building experimental aircraft.Karthik ManjunathaKarthik is a Senior Automotive Industry Specialist helping customers to define and develop solutions in various automotive workloads. He has worked on Location based services for over a decade and has lead off-board and on-board routing development with several OEMs. Currently at AWS he is working on initiatives for sustainable EV Adaption and Connected mobility solutions.Shane JordanShane is a Senior Solutions Architect working with the AWS Industries & Automotive team. He helps customers in designing, building, and operating Well-Architected systems on AWS. He has more than 25 years experience in software and technology and has started multiple startup companies.
The fleet management market is expected to grow at a Compound Annual Growth Rate (CAGR) of 15.5 percent—from 25.5 billion US dollars in 2022 to USD 52.4 billion in 2027. Optimizing how your organization uses its vehicle fleet is important for logistics and service providers such as last mile, middle mile, and field services. In […]
Mahesh Geeniga
Amazon DynamoDB Amazon Location Amazon Simple Storage Service (S3) Architecture AWS Cloud Development Kit AWS Lambda Technical How-to