Optimization Report
Optimization Report
Optimization IE402
Professor
Prof. Manoj Raut
Made by
Shreyansh Vyas - 202101022
Lav Chaudhari - 202101135
INTRODUCTION
In today’s world, everyone wishes not only to complete the work but to complete the work
in minimum amount of time and with minimum resources.For example: A truck delivering goods
to various shops or a postman deliv-ering posts to various homes. The truck driver wishes to
spend less on petro land the same applies for the postman.
So we will discuss this problem and the possible solutions to it and which solution is better.
The problem is called ’The travelling salesman problem’.
EXPLANATION OF PROBLEM
The Travelling Salesman Problem (also known as Travelling SalespersonProblem or TSP)
is a renowned NP-hard problem as no ‘quick’ solution has been found till now.
The travelling salesman problem is about starting from a point and passing through all the
points (destinations) exactly once and returning back to the starting point by covering the
minimum distance.
The Travelling Salesman Problem is a problem aimed at minimising the amount of energy
expenditure. In this problem, there are a set of nodes(or cities), and a salesperson, starting from
a city (say hometown), travels through each one of them exactly once to advertise his product
and return to his hometown in the end. The salesman completes the job by covering the least
distance to stay economical.
So, one has the adjacency matrix of a particular quantity between the pairs of cities (or
nodes) that could have everything that has to be minimised. The adjacency matrix may contain
the cost of travelling between all the possible pairs of cities, the distance between every pair of
cities, or any such constraint.
1. Logistics: TSP can be used to optimise the route of delivery vans and calculate the shortest
route for delivery.
2. Manufacturing: TSP can be used to optimise the route for an assembly line, thus reducing
production costs.
3. Network Design: TSP can be used to design the layout of a computer network by
optimising the route of the cables.
4. Education: TSP can be used to plan the most efficient route for a school bus to pick up and
drop off students.
5. Military Applications: TSP can be used to identify the optimal route for an army to take in
order to attack a particular target.
6.GPS System: The GPS is an application to the TSP. Google Maps would provide the
traveller with the shortest possible route to reach the destination.It re-routes to the best way if
the traveller changes his mind.
7.Airline crew scheduling: Airlines also assign rights to the crew members in a way that
they return to their hometowns.
8.Routing long-distance trains: Long-distance trains are routed in the bestway to conserve
fuel and energy.
SOLUTIONS
● Let the hometown of the salesman be node 1
● Let the adjacency matrix shown be the cost required for travelling from one node to
another.
● In the adjacency matrix, the column numbers determine the start point o the salesman at
a particular instance & the row numbers represent the final point of the salesman with
that traversal
1) Greedy algorithm
❖ One approach is the use of Greedy Algorithm. As per the Greedy Algorithm, the
salesman initially goes to the point which consumes the least energy.
❖ So, as per the above example, the salesman will go to the second city first. Then, the
algorithm will again search for the best location. Thus, the salesman will go to city 4.
❖ Here, the algorithm won’t allow the salesman to return to the first city,though it is cheaper
than travelling to the fourth city because doing so will complete the loop without covering
all the cities, leading to an overall in-crease in the cost of covering all the cities just once.
With the use of the Greedy Algorithm.
❖ The path of traversal would be:1→2→4→3 →1.
❖ The cost calculated on the basis of the above traversal would be 10 +10 +
20 + 15 which equals 55.
❖ The answer obtained based on the Greedy Algorithm is correct but we can’t comment on
the optimization of this solution.
❖ So, it can be concluded that this algorithm is unconcerned with whether the most
excellent outcome at the moment will produce the final best result.
❖ The time complexity while using Greedy algorithm is O(n2*log2(n)).
4) Dynamic Programming
❖ The most efficient method to solve the TSP is Dynamic Programming.
❖ This method gives the guaranteed solution. Though the time complexity for solving the
TSP remains exponential, it reduces the time complexity as compared to other
methods.[3]
❖ In this method, the problem is solved in a Bottom-up approach. TheDynamic
Programming is beneficial:
❖ only when the problem is getting divided into smaller sub-problems (the solution to the
problem is obtained by combining the solutions of the sub-problems in which it is
divided)
❖ there is repetition/overlapping in the sub-problems (the benefit of this is that we can
once store the value o the repetitive portion and use it as and when required)
❖ The time complexity while using Dynamic Programming is O(n2*2n).
❖ So, the best solution after taking into account both the results and time complexity turns
out to be Dynamic Programming.
❖ The method which would definitely obtain the optimal solution of TSPis the method of
exhaustive enumeration and evaluation.
Solutions:
1) Hybrid Genetic Algorithm
2) Dynamic Programming
3) Greedy Algorithm
4) Brute force method/ Naive method
5) The Nearest Neighbour Method
The answer obtained when the problem is solved using the Greedy algorithm is inaccurate, so it
is not the most optimal solution. The time complexity for solving the travelling salesman problem
using Dynamic Programming is exponential, i.e., O(n2*2n), but still it is less than O(n!), which is
the time complexity of Brute Force Approach.
#include <iostream>
int maximum = 1000000; // Here we have assumed a maximum value to prevent overflow in
calculating the minimum cost
if (cache [k][box] != 0)
return cache [k][box];
int answer = maximum; // The minimum cost for traversing all the nodes
/* In order to find the minimum cost, we have to traverse all the p nodes in box and end our
path at kth node.
Hence, with the help of dynamic programming, we are recursively calling solve function to
calculate cost of traversing
all nodes in box except k. Then we will traverse back from node p to k by taking the path
that has minimum cost of all
the available paths.
*/
cout << "Now let's make a matrix of cost of going from one node to another node" << endl <<
endl;
// steps [x][y] represents the minimum steps or cost required to go from a node x to node y
cout << "Enter the cost of going from node " << x << " to node " << y << " : ";
cin >> steps [x][y];
cout << endl;
}
}
cout << "The matrix of cost that you have entered is as follows : " << endl << endl;
cout << " ";
cout << "The minimum cost/steps required to traverse through all the nodes = " << sol <<
endl << endl;
return 0;
}
Output:
References
[1] In: (). url:
https://aip.scitation.org/doi/pdf/10.1063/1.4976899#:~:text=The%20traveling%20salesman%20p
roblem%20.
[2] In: ().url:
https://www.tutorialspoint.com/design_and_analysis_of_algorithms/design_and_analysis_of_alg
orithms_travelling_salesman_problem.htm.
[3] In: (). url: https://en.wikipedia.org/wiki/Dynamic_programming.