Professional Documents
Culture Documents
I.
General Algorithm
I.I. SA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
s e t i n i t i a l temperature T
generate i n i t i a l solution s
f = evaluate ( s )
fopt = f
while e v a l _ c o u n t < eval_budget
f o r 1 : k / k i s t h e amount o f t r i a l
per temperature /
g e n e r a t e a new s o l u t i o n s / a c c o r d i n g
t o mutation f u n c t i o n /
f = evaluate ( s )
if f < f
fopt = f / update f /
s = s
/update s /
else
p = exp ( ( f f ) /T )
i f p > randon p r o b a b l i t y
s = s
/update s /
fi
fi
end f o r
update T
end while
Important factors that influence the convergence velocity are first, how the temperature
changes, second how to generate the new can-
I.II. GA
1 g e n e r a t e f i r s t g e n e r a t i o n with p o p u l a t i o n
mu
2 evaluate the parents
3 while not t e r m i n a t e d
4
f o r k = 1 t o lambda ( t h e amount o f t h e
children )
5
s e l e c t one p a r e n t p i a c c o r d i n g t o
their fitness
6
i f pc > rand ( )
7
apply t h e s e l f c r o s s o v e r t o p i then
generate offspring_k
8
fi
9
i f pm > rand ( )
10
apply t h e s e l f mutation t o
offspring_k
11
fi
12
end f o r
13
e v a l u a t e t h e lambda o f f s p r i n g
14
s e l e c t t h e b e s t mu c a n d i d a t e s among both
t h e o f f s p r i n g and t h e p a r e n t s
15
p a r e n t s = mu b e s t c a n d i d a t e s
16 end while
II.
Mutation
1 P_row=ones ( 1 , n^2) ;
2 for i = 1: n
3
for j =1:n
4
i f abs ( sum ( s ( j , : , i ) ) ) == s t d
5
P_row ( j +( i 1)n ) = 0 . 1 2 5 ;
6
e l s e i f abs ( sum ( s ( j , : , i ) ) s t d ) <
std 0.001
7
P_row ( j +( i 1)n ) = 0 . 5 ;
8
e l s e i f abs ( sum ( s ( j , : , i ) ) s t d ) <
std 0.005
9
P_row ( j +( i 1)n ) = 0 . 7 ;
10
e l s e i f abs ( sum ( s ( j , : , i ) ) s t d ) <
std 0.01
11
P_row ( j +( i 1)n ) = 0 . 8 5 ;
12
e l s e i f abs ( sum ( s ( j , : , i ) ) s t d ) <
std 0.015
13
P_row ( j +( i 1)n ) = 0 . 9 5 ;
14
fi fi fi fi fi
15
end f o r
16 end f o r
17 f o r i = 1 : n^2
18
i f P_row ( i ) > rand ( 1 )
19
index ( k +1) = i ;
20
k= k + 1 ;
21
fi
22 end f o r
III.
Parameters in SA
k
125
100
90
80
70
60
50
40
30
20
10
5
exp1
248.2
160.0
132.5
146.2
92.7
102.5
120.6
106.8
71.3
44.3
28.6
11.5
fopt
exp2
181.2
187.9
208.1
175.9
147.1
127.1
93.3
89.5
90.8
39.3
24.9
29.7
group
exp3
259.1
202.2
180.0
121.7
126.6
118.7
36.3
103.2
61.0
42.6
24.8
13.3
III.II.
p2p weight(%)
1.38
1.20
1.41
fopt
56497
69182
57236
group2
3.99
5.19
5.22
75597
59455
55321
63457
group3
14.73
14.34
15.93
48366
48309
51345
49340
group4
25.34
26.27
24.36
41490
49563
51839
47630
group5
35.36
33.86
35.09
36224
48402
47287
43971
group6
43.58
45.71
44.54
29547
35343
28725
31205
group7
55.16
53.81
53.63
19605
35499
23085
26063
group8
64.85
65.42
65.24
24137
26794
18064
22998
74.21
74.90
75.61
84.64
85.24
84.16
22535
19179
18971
12620
574
22227
94.33
93.82
93.43
16569
28230
17203
group1
group9
A variable pm is created to determine
which kind of operation mutation would be
selected every time.
group10
group11
1 i f pm > rand ( 1 )
2
p o i n t t o p o i n t swap o p e r a t i o n
3 else
4
s t r i n g t o s t r i n g swap o p e r a t i o n
5 fi
avg
60971
20228
11807
20667
Table 2: How different focus on two kind of mutations respectively affects the cnovergency velocity. budget: 40000)
Exp No.
1
2
3
15
20
25
fopt(104 )
5.3121
3.7240
3.4086
4
5
6
10
30
40
50
5.8163
4.3294
3.2191
7
8
9
15
45
60
75
6.3917
5.2165
4.3925
difference (%)
probability
0
0.1
0.5
1
1.5
>1.5
0.125
0.5
0.7
0.85
0.95
1
IV.II.
Pm and Pc
pc
Exp No.
1
2
3
0.8
pm
0.2
0.4
0.6
fopt(104 )
3.4056
1.9977
1.7689
4
5
6
0.7
0.2
0.4
0.6
2.5285
1.6253
0.85744
7
8
9
0.6
0.2
0.4
0.6
2.0687
1.1712
0.57004
IV.
IV.I.
Parameters in GA
Population
V.
Result
V.I.
V.II.
Data
The following is the result of several experiments respectively on magic square and
magic cube.
Magic square:
Exp No.
fopt
avg
1
2
3
4
5
6
7
8
9
10
11
7.9231
11.3077
17.6538
13.5769
14.8769
17.9231
22.3077
14.7308
21.1923
22.3546
19.7692
16.6224
Consider the fopt is the MSE to the standard sum, thus a difference around 4 to the
standard sum can be obtained within 50000
iterations.
Magic cube:
Figure 4: large iteration times
Exp No.
fopt 104
1
2
3
4
5
6
7
8
9
3.0899
3.5891
3.4587
3.0885
3.3267
3.5223
3.3424
3.0797
3.3062
avg 104
3.3115
VI.
10
11
From the data above and the figure below we can see that both SA and GA has a fast speed
at the beginning but in the long run it could not behave better and may stopped at some local
optimum however, GA can behave better in the long run and when using GA to solve both magic
square, with in 10000 evaluate budget we can always have the oppotunity to find fitness below 1
and when it comes to the magic cube, we have the oppotunity to get fitness under 1000 within
10000 evaluate budget. This indicates GAs fast convergence to solve the problem. And using SA
the result is always stable which can ensure a better solution to be find.
12