1: Tune initial temperature ( )
2: Tune final temperature ( )
3: Setting the factor cooling
4: Setting with
5: Add to and to
6: Calculate similarity of
7: =
8: Setting
9: While ( > ) do
10:   = 1
11:  While ( > )
12:    Create adding or removing gap to
13:    Calculate similarity of
14:    Obtain difference of similarity between and
15:    If (difference 0) then
16:      =
17:     If similarity ( ) > similarity ( ) then
18:       =
19:      Add S better to SS betters
20:     end if
21:    else
22:     Boltzmann probability = exp(-difference/ )
23:     If (Boltzmann probability) > random(0,1) then
24:      S current = S new
25:     end if
26:    end if
27:     = + 1
28:   end while
29:   Descrease
30:   Increase
31:   Randomly Choose S current of SS betters, S better o S original
32: end while
Algorithm 3: Pseudo code of SAPS.