Assignment No 2
Assignment No 2
QUESTION#1
Travelling sales man problem appears in different real life scenarios mention these.
Solution:
The Traveling Salesman Problem (TSP) appears in many real-life scenarios where
optimizing a route or minimizing travel costs is essential. Here are some common examples:
6. Drone-Based Delivery
8. Garbage Collection
Here I am taking a scenario from logistics and delivery service. Companies like Amazon,
FedEx, or DHL need to plan optimal delivery routes to minimize distance, time, and fuel
costs for their delivery trucks or drones.
EXAMPLE:
A salesman has to travel to all these 4 cities, his starting point is A
and he has to visit all the remaining 3 cities atleast once and then
he has to come back to the starting city.
We can represent this as a graph
where:
Nodes represent the locations (including the node A).
Edges represent the paths between the locations, and the
weights on the edges represent the distance (or time, cost)
between the two locations.
Graph Representation
Locations (Nodes):
1. Customer A (A)
2. Customer B (B)
3. Customer C (C)
4. Customer D (D)
B C D
C D B D B C
D C D B C B
A A A A A A
Steps
Step 1: Generate All Possible Routes (Permutations)
Using brute force, we will generate all possible routes starting from A and visiting all other
nodes exactly once, then returning to A. There are (n−1)!(n - 1)!(n−1)! possible routes, where
n is the number of nodes (locations). In our case, for 4 nodes, we have (4−1)!=3!=6(4 - 1)! = 3!
= 6(4−1)!=3!=6 possible routes.
Step 2: Calculate Total Distance for Each Route.
Step 3: Find the Optimal Solution.
By using brute force we will find out the optimal force.
Output
Best Route: ('a', 'b', 'd', 'c', 'a')
Minimum Distance: 80