Skip to content

abhijeet2096/tsp_sa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travelling Salesman Problem Solution By Modified Simulated Annealing Algorithm

T.S.P

TSP problem is one of the most famous hard combinatorial optimization problems. It belongs to the class of NP-hard optimization problems. This means that no polynomial time algorithm is known to guarantee its global optimal solution. Consider a salesman who has to visit cities. The TSP problem consists of finding the shortest tour through all the cities such that no city is visited twice and the salesman returns back to the starting city at the end of the tour.

'f' is the cost function and 'd' is the distance between two nodes and p(i) is an array of paths by salesman

f = Σd(p(i))

delta = f1 -f2

S.A (Simulated Annealing)

SA algorithm is commonly said to be the oldest among the metaheuristics and surely one of the few algorithms that have explicit strategies to avoid local minima. The origins of SA are in statistical mechanics and it was first presented for combinatorial optimization problems. The fundamental idea is to accept moves resulting in solutions of worse quality than the current solution in order to escape from local minima. The probability of accepting such a move is decreased during the search through parameter temperature

Here 'p' is the probability of the move and 'T' is our temperature.

p = 1/(1 + e^(delta(f)/T))

Modified S.A

we used the Greedy hybrid operator to move to the neighbouring node. We first choose randomly to index 'i' & 'j' and operator three operations viz inverse insert and swap and calculated the 'p' for each possible path and if it was greater than randomly generated probability 'r' we moved forward else we continued.

  1. Inverse operator : It reverses the subpath from path from indexes 'i' and 'j'.
  2. Insert operator : It cycles down the subpath from indexes 'i' and 'j'.
  3. swap operator : It swapes the path[i] and path[j] elements.

Temperature Simulation.

we used the classical geometric cooling schedule for simulated temperature cooling.

Instruction

  1. Clone the above repo by
     $ git clone https://github.com/abhijeet2096/tsp_sa
    
  2. Spawn terminal in cloned folder.
  3. Compile using $ make .
  4. Run above program as
     $ ./tsp < ./TestCases/euc_100
    
  5. Check stdout for output !

Results

Results are displayed below in table.

TestCase Distance
euc_100 1497.217651
euc_250 2516.678467
euc_500 3554.416260
noneuc_100 5216.49072
noneuc_250 12799.088867
noneuc_500 25380.828125

About

The Assignment's aim was to solve Travelling salesman problem. This Assignment was under Prof. Deepak Khemani.

Contributors

Abhijeet sharma

  1. Github: http://github.com/abhijeet2096
  2. Email: sharma.abhijeet2096@gmail.com
  3. Mobile: +91-8629015433

Swapnil Sharma

  1. Github: http://github.com/swapsha96
  2. Email: swap.sha96@gmail.com
  3. Mobile: +91-8629015435

References

  1. https://www.youtube.com/watch?v=dg5zUxdAE_E&list=PLbMVogVj5nJQu5qwm-HmJgjmeGhsErvXD&index=14
  2. https://www.hindawi.com/journals/cin/2016/1712630/#B25

About

Travelling salesman problem in c

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published