Giter VIP home page Giter VIP logo

simulated-annealing's Introduction

Simulated Annealing

Author: Ilya Borovik, BS4-DS

Application of Simulated Annealing to the Travelling Salesman problem as a solution to Assignment #2 in Advanced Statistics course at Innopolis University.

The task is to solve the Traveling Salesman problem for the 30 most popular Russian cities.

Report

Images and plots

Video animations

Installation

To run the code yourself:

  • clone repository using git clone https://github.com/ilya16/simulated-annealing
  • install dependencies using pip install -r requirements.txt

Dataset

Initial dataset contains a description of all cities in Russia. The top 30 cities are chosen by the population.

Simulated Annealing algorithm notes

SA implementation follows the notes from the Task. A few considerations are made to improve performance:

  • Path distances are computed in constant O(1) time by observing the fact that two successive paths x_{t+1} and x_{t} differ only in two positions.
  • Early stopping is used when acceptance ratio alpha becomes equal to np.nan. Acceptable non-nan paths are observed and one of them is chosen at random to continue the search. When all possible paths cannot be accepted (alpha=np.nan for all new paths) algorithm ends execution. A more detailed description is available in report

Experimental setup

Simulated Annealing is compared for four different values of annealing rate: 0.9 (fast), 0.95 (middle), 0.99 (slow) and 0.997 (very slow).

For each experiment run the same initial path is used:

Results

Distances of optimal paths for each annealing rate and number of taken iterations are shown in the table below:

Annealing Rate # of iterations Optimal path distance
0.9 177 31722.88 km
0.95 377 24951.07 km
0.99 2033 18245.96 km
0.997 6813 17908.49 km

Combined convergence rates plot:

Convergence rates and optimal paths for each annealing rate are shown below.

Fast cooling (ann_rate=0.9)

Convergence animation

Middle cooling (ann_rate=0.95)

Convergence animation

Slow cooling (ann_rate=0.99)

Convergence animation

Very Slow cooling (ann_rate=0.997)

Convergence animation

Conclusion

Simulated Annealing can indeed solve the Traveling Salesman problem and find optimal (to some extend) solutions in a small amount of time.

Slow cooling in SA converges to a better solution, however, results may depend on the pseudo random procedure of sampling the next path from the distribution of paths.

simulated-annealing's People

Contributors

ilya16 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.