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.

- Evaluate the initial order
- current order := initial order
- BEST-SO-FAR := current order
- TEMP := constant, STOP_TEMP := constant, COOLING_RATE := constant
**UNTIL** TEMP < constant **DO**
- Create new order by swap randomly one pair of current order
- Evaluate new order

IF new order is better than the current order **THEN****{**

+current order := new order

+IF 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 { **

+ := distance of current order – distance of new order

+IF ** THEN**

++current order := new order

}
- Revised TEMP by multiply with COOLING_RATE

- 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.

### Like this:

Like Loading...

*Related*