Simulated Annealing Algorithm for TSP

Today, I am trying to solve TSP (Traveling Salesman Problem) by using simulated annealing algorithm. That means I have to make a loop with injecting other case of path to the algorithm. Here is the pseudo-code for simulated annealing algorithm.

  1. Evaluate the initial order
  2. current order := initial order
  3. BEST-SO-FAR := current order
  4. TEMP := constant, STOP_TEMP := constant, COOLING_RATE := constant
  5. UNTIL TEMP < constant DO
    1. Create new order by swap randomly one pair of current order
    2. Evaluate new order
      new order is better than the current order THEN{
      +current order := new order
      the new order is better than BEST-SO-FAR THEN{
      ++BEST-SO-FAR := new order }
      ELSE IF
      the new order is not better than the current order  THEN {
      +{\Delta}E := distance of current order – distance of new order
      e^{-{\Delta}E/T}>random(0,1) THEN
      ++current order := new order
    3. Revised TEMP by multiply with COOLING_RATE
  6. Return BEST-SO-FAR as the answer

As I hope you might see 5.1, the algorithm will create another order for evaluation by swapping randomly. This is not good and causes in an ineffective result since the new created order will be the same with the old one again and again. The best solution for this may be permutation. Let’s see the link for how to use permutation in programming.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s