Blog

Pizza Edition GitHub: Solving the Travelling Salesman Problem

Introduction

Have you ever wondered how a pizza delivery driver can quickly deliver pizzas to multiple houses? Well, that’s where the Travelling Salesman Problem (TSP) comes into play. The Travelling Salesman Problem is a classic math problem that helps find the fastest way for someone to visit a set of locations and return to the starting point. In this article, we will explore how this problem was solved in a college project called “Pizza Edition,” which is available on GitHub. The project uses clever algorithms to minimize delivery time and keep pizza customers happy!

What is the Travelling Salesman Problem?

The Travelling Salesman Problem (TSP) asks: if a salesman has to visit a list of cities, what is the shortest path he can take that visits each city exactly once and returns to the starting city? This problem is difficult to solve because there are many different ways the salesman can travel between the cities. For example, if there are just five cities, there are 120 possible routes. As the number of cities grows, the possible routes grow even faster, making it much harder to find the best route.

In the Pizza Edition project, this problem was tackled with a fun twist—delivering pizzas to houses instead of visiting cities. The goal was to find the quickest route to deliver pizzas, while reducing the number of customers who have to wait more than 30 minutes for their pizza.

How the Project Works

The Pizza Edition project uses several clever steps to solve the Travelling Salesman Problem. Here is an overview of how it works:

  • Input Data: The project starts by inputting the details of each delivery. This includes:
    • Delivery number
    • House address
    • Waiting time in minutes
    • GPS coordinates (north and west)

    These details are then used to calculate the distance between each house and how long the customers have been waiting.

  • Distance Calculation: The project uses a mathematical formula called the Haversine formula to calculate the distance between houses based on their GPS coordinates. This is important because the delivery driver needs to know how far apart the houses are in order to plan the best route.
  • Minimizing ‘Angry Minutes’: The project also keeps track of “angry minutes,” which are the extra minutes customers wait after 30 minutes. The goal is to keep these angry minutes as low as possible by finding the fastest route.

Algorithms Used to Solve the Problem

To solve the Travelling Salesman Problem, the Pizza Edition project uses a combination of different algorithms. Let’s break down each one:

  • Nearest Neighbour Algorithm: This algorithm starts at one house and always visits the closest house next. In the project, the algorithm also gives a little extra preference to houses that have been waiting longer, so customers with longer wait times are served earlier.
  • Randomisation: Once the nearest neighbour algorithm has generated a possible route, the project randomizes the route three million times! This helps find a shorter route than the one created by the Nearest Neighbour method alone.
  • 2-opt Algorithm: After randomization, the project runs the 2-opt algorithm, which checks for any crossed-over paths. If the algorithm finds a cross, it swaps the path to make it shorter. This fine-tunes the delivery route and ensures the driver takes the shortest possible path.

The Graphical Output

One of the fun parts of this project is the graphical interface! The project doesn’t just solve the problem—it also displays the results in a way that’s easy to understand. The interface includes:

  • Text boxes for input and errors: There is a large text box for entering delivery data, and a smaller box that shows the route in order of delivery. It also displays any errors, such as incorrect data or missing details.
  • Route Visualization: Once the delivery route is calculated, the houses are shown on a map. A motorbike driver zips between the houses on the map, followed by a dotted red line, showing the path taken.
  • Angry Minutes Clock: A cartoon-style angry clock shows the number of angry minutes. This gives a fun, visual way of tracking how late the deliveries are.

Why the Project is Useful

The Pizza Edition project is more than just a fun experiment. It has practical uses in many different industries where deliveries or services are involved. For example:

  • Pizza Delivery: As in the project, companies that deliver food can use similar methods to make sure their customers get their food quickly and aren’t left waiting too long.
  • Courier Services: Courier companies can use the same algorithms to find the shortest route for delivering packages.
  • Ride-Sharing: Ride-sharing companies like Uber or Lyft can use algorithms like the ones in this project to find the fastest routes for their drivers.

Using tools like the Pizza Edition project helps companies save time, money, and keep their customers happy.

How to Use Pizza Edition on GitHub

If you are interested in using the Pizza Edition project yourself, you can easily download it from GitHub. The project uses simple Java libraries, so it is easy to run on most computers. Here’s a quick guide to getting started:

  • Step 1: Go to GitHub and search for “Pizza Edition”.
  • Step 2: Download the project files.
  • Step 3: Input your own data, such as delivery addresses and wait times.
  • Step 4: Run the project, and watch the motorbike driver zip from house to house while tracking the “angry minutes.”
  • Step 5: Try experimenting with different data to see how the route changes.

The project even includes sample data so you can test it out right away!

Conclusion

The Pizza Edition project is a creative and practical way to solve the Travelling Salesman Problem. By using clever algorithms and a fun visual interface, it makes finding the best delivery route simple and efficient. Whether you’re delivering pizzas or working on any other type of delivery service, the Pizza Edition project on GitHub can be a great tool to help improve your operations. Give it a try and see how it can help you deliver with speed and accuracy!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button