Skip to content

jvspeed74/Route-Optimization-And-Visualization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Route-Optimization-And-Visualization


Project Overview

This project delivers a two-day food-truck tour around the IUPUI campus in Indianapolis. It combines Google Maps APIs with Python-based route-optimization algorithms to generate a data-driven itinerary across 14 food-truck locations, minimizing travel time while maximizing coverage.


Where's the Code?

Recommended: Use this link to launch the Google Colab environment of the project for an interactive experience:

Open In Colab


Background and Motivation

In October 2023, during my junior year at Indiana University–Purdue University Indianapolis (IUPUI), I developed this project as part of my application to the Xtern Talent Program, a selective initiative that connects emerging technology talent with Indiana-based companies.

Applicants were given a deliberately open-ended prompt:

“Create a weekend foodie plan around Indianapolis utilizing Google Maps APIs.”

Rather than submitting a simple itinerary, I treated the prompt as a technical challenge: how could a casual planning task be turned into a problem that meaningfully demonstrated data science and software engineering skills?

With only one weekend available between schoolwork and extracurriculars, I completed the entire project—from initial concept to final submission—under significant time pressure, requiring disciplined scope management and strategic prioritization.


Technical Approach

I reframed the weekend plan as a route-optimization problem. The goal was to determine the most efficient way to visit a large number of food trucks near campus within a limited time window.

To accomplish this, I:

  • Pulled real-world location and distance data using Google Maps APIs
  • Modeled the itinerary as an optimization problem
  • Used Python-based algorithms to compute efficient travel sequences
  • Produced a structured two-day schedule that minimized travel overhead while preserving practical usability

This turned a vague prompt into a reproducible, data-driven solution grounded in real constraints.


Results and Impact

The project was a major factor in my selection for the Xtern Program, which evaluated more than 1,000 applicants through four competitive elimination rounds. Submissions were reviewed by industry professionals for both technical depth and execution quality.

Advancing through the program led to interviews with multiple companies, including Sallie Mae and Franciscan Health. I accepted an internship with Sallie Mae for Summer 2024, which continued part-time through my senior year and culminated in a full-time offer in May 2025.

This project directly initiated a long-term professional relationship and demonstrated my ability to:

  • Identify real-world problems
  • Integrate multiple APIs
  • Apply algorithmic thinking
  • Deliver a polished technical product under time constraints

Key Takeaway

This project exemplifies curiosity-driven engineering: starting with a loose requirement and elevating it into a technically rigorous, real-world solution that stands out through thoughtful use of data, APIs, and optimization techniques.


Project Architecture

Data Directory Structure

data/
├── Distance Matrix API (Data Tables)/
│   ├── baseline_distance_travel_data.csv      # Template structure
│   └── updated_distance_travel_data.csv       # Populated with API data
├── Initial Data Cleaning/
│   ├── baseline_food_trucks.csv               # Raw API output
│   └── cleaned_food_trucks.csv                # Manually cleaned dataset
└── Weekend Plan (Route and Location Information)/
    ├── foodtruck_information.csv              # Final food truck details
    ├── route_information.csv                  # Daily route information
    ├── Day1GoogleRoute.PNG                    # Day 1 visual route map
    └── Day2GoogleRoute.PNG                    # Day 2 visual route map

1. Data Collection Phase

  • Google Places API: Queries for food truck locations within 5 miles of IUPUI campus center (coordinates: 39.7743, -86.1764)
  • Output: baseline_food_trucks.csv containing name, address, rating, price level, URL, hours, location ID, coordinates, and initial distance data
  • Key Function: get_data(api_key) - retrieves food truck information from Google Maps Places API

2. Data Cleaning & Preparation

  • Input: baseline_food_trucks.csv
  • Output: cleaned_food_trucks.csv
  • Cleanup Actions:
    • Removed locations with incompatible operating hours
    • Removed low-rating locations (rating < 1.0)
    • Manually added cuisine type data
    • Standardized URLs with manual verification
    • Added day-specific hours (Friday/Saturday)
    • Cleaned coordinate formatting
    • Assigned unique location IDs for easier sorting
  • Final Dataset: 14 food truck locations with complete operational information

3. Distance Matrix API Integration

  • Process:
    1. Generated baseline distance matrix from cleaned locations to all destinations
    2. Queried Distance Matrix API for precise distance and travel time data
    3. Populated missing distance and duration metrics
    4. Created distance matrix in kilometers for optimization algorithm
  • Data Files:
    • baseline_distance_travel_data.csv - template structure
    • updated_distance_travel_data.csv - completed with API data

4. Route Optimization

  • Algorithm: Python TSP (Traveling Salesman Problem) with simulated annealing heuristic
  • Input: Distance matrix (14 x 14 locations)
  • Output: Optimized route permutation minimizing total travel distance
  • Result: Efficient two-day itinerary with 7 locations per day

5. Weekend Foodie Plan

  • Deliverables:
    • foodtruck_information.csv - All food truck details with route position assignments
    • route_information.csv - Daily route information including travel times and cumulative distances
    • Day1GoogleRoute.PNG - Visual route map for Day 1
    • Day2GoogleRoute.PNG - Visual route map for Day 2
  • Features:
    • Route positions for each location
    • Operating hours (opening/closing times)
    • Estimated 30-40 minute stops per location
    • Total trip distance and duration per day
    • All data organized by importance and relevance

6. Visualization

  • Generated Google Maps route images for both days

Day 1 Route Visualization:

Day 1 Route


Day 2 Route Visualization:

Day 2 Route


Technology Stack

Platforms

  • Google Colab: Cloud-based Jupyter notebook environment for code execution and documentation

Libraries & APIs

  • pandas: Data manipulation and CSV processing
  • googlemaps: Google Maps Places API and Distance Matrix API integration
  • python_tsp: TSP solving with dynamic programming and simulated annealing algorithms

Core Dependencies

pandas
googlemaps
python_tsp

Project Execution Flow

Required Order of Operations:

  1. Initialize Packages - Install and import all dependencies
  2. Google Maps API Integration - Set up API functions for data collection
  3. Main Script - Execute data gathering with valid API key
  4. Data Cleaning - Review and manually clean baseline dataset
  5. Distance Matrix API Integration - Populate distance and travel time metrics
  6. Route Optimization - Apply TSP algorithm to calculate optimal route
  7. Weekend Foodie Plan - Generate final itinerary and visualizations

Key Functions:

  • get_input() - User prompt for data collection initiation
  • get_key() - API key input validation
  • get_data(api_key) - Retrieves food truck data from Google Places API
  • format_data(data) - Cleans and exports initial dataset to CSV
  • solve_tsp_simulated_annealing() - Optimizes route using simulated annealing heuristic

Design Decisions & Implementation Notes

Route Optimization

  • Algorithm Choice: Simulated annealing was selected for its effectiveness on TSP problems with reasonable compute time
  • Result: Minimized total travel distance across 14 locations split into two days

Data Quality

  • Manual verification and cleaning was necessary due to API inconsistencies (missing prices, invalid IDs, incomplete hours)
  • Location filtering based on rating ensured only quality establishments were included

Time Allocation

  • 30-40 minute buffer per location accommodates ordering and eating
  • All routes respect operating hours constraints for both days
  • Total distance per day kept realistic for weekend itinerary

Future Enhancements

  • Integration of additional points of interest in Indianapolis
  • Multi-modal transportation options (cycling routes)
  • Dynamic pricing and menu data integration
  • Real-time travel time adjustments based on traffic patterns

About

Integrated the Google Maps API with Python (Pandas and NumPy) to collect, process, and analyze food-truck location data, including travel distances and times. Applied dynamic programming and simulated annealing to compute optimal delivery routes.

Topics

Resources

Stars

Watchers

Forks

Contributors