1: Tune initial temperature ( )
2: Tune final temperature ( )
: Setting cooling factor
4: Create from Initial solution
5: Calculate similarity of
6: =
7: Setting
8: While ( > ) do
9:   = 1
10:  While ( > )
11:   Create adding or removing gaps to
12:   Calculate similarity of
13:   Obtain difference similarity between and
14:    If (difference 0) then
15:     Scurrent = S new
16:     If similarity ( ) > similarity ( ) then
:        =
:    end if
19:   else
20:    Boltzmann probability = exp(−difference/ )
21:    If (Boltzmann probability) > random(0,1) then
22:      =
23:   end if
24:   end if
25:    = + 1
26:  end while
27:  Descrease
28:  Increase
29: end while
Algorithm 2: Pseudo code SA applied to Sequence Alignment.