Algorithms
  • Introduction
  • Algorithms
    • Insertion Sort
    • Shell Sort
    • Selection Sort
    • Heap Sort
    • Merge Sort
    • Quick Sort
    • Dual Pivot QuickSort
    • Radix Exchange Sort
  • Data Structures
    • Basic Datastructures
      • Table or Array
      • List
      • Linked List
      • Stack
      • Queue
      • Deque
      • Dictionary
      • HashTables
    • Trees
      • Tree
      • Binary Search Tree
      • Heap
      • Red-Black Trees
      • Splay Trees
      • Randomized Search Trees
    • Dynamic Programming
      • Fibonacci
      • Knapsack
      • Optimal Binary Search Trees
      • Longest Common Sub sequence
    • External Data Structures
      • B-Trees
      • Variants
    • Multi-dimensional Data Structures
      • Point-Region Quadtree
      • Point-Quadtrees
    • Priority Queues
      • Binomial Queues
  • Graphs
    • Basics
    • Depth First Search
    • Applications of Depth First Search
    • Breadth First Search
    • Shortest Paths
    • Transitive Closure
    • Flow Networks
    • Matching
  • Strings
    • Data Structures for Strings
      • Tries
        • Binary Tries
        • Multiway Trie
        • Patricia Tries
      • Variable Length-code
        • Elias Code
        • Gamma Code
        • Fibonacci Code
      • Huffmancode
      • Ternary Search Tree
    • Searching in Strings
      • Prefix Function
      • Knuth-Morris-Pratt
      • Boyer-Moore
      • Monte-Carlo Algorithms
      • Karp-Rabin
      • Automatons
      • Shift-AND
    • Indexing Text
      • Suffix Trees
      • Suffix Arrays
      • Search Engines & Inverted Files
  • P and NP
    • Introduction
    • SAT and 3-SAT
    • Graph Problems
    • Problems with Collections
    • Networks
    • Data storage
  • Metaheuristics
    • Trajectory Methods
      • Local Search
      • Simulated Annealing
      • Tabu Search
    • Population Based
      • Ant Colony
      • Evolutionary Computation
  • Sources
Powered by GitBook
On this page

Was this helpful?

  1. Metaheuristics
  2. Trajectory Methods

Simulated Annealing

Simulated annealing comes from the metalwork, where they heat a metal object to make sure that there are no errors or cracks in it. After the heating process, they will then cool down the metal object in phases to prevent cracks later on.

To apply this algorithm, we start with a high temperature. This high temperature allows the algorithm to escape any local optimums (it thus accepts values worse then our current). As the temperature gets reduced, we decrease the chance of worse values being accepted.

In code we can explain this by picking a start temperature which is our probability for a value to be accepted. Then when we find a new value, if it is better we can instantly accept it, but if it is worse, we accept it with a specific probability. To explain this better, let's say we have a worse value, now we throw a dice and when it is a 1 or a 2, we accept the worse value. After each iteration this temperature now decreases and we will only accept a 1. After a while, the probability will be so low that only better values are accepted.

Algorithm

  1. Create Initial Solution S and set our begin temperature T

  2. While(termination not met)

    1. Pick a new solution at random by making a small change to our current solution

    2. Do we go to this new solution? (check if acceptanceProbability(old, new, temperature) > Math.random())

    3. Decrease the temperature and continue loop

PreviousLocal SearchNextTabu Search

Last updated 6 years ago

Was this helpful?