recombination:重组算法(Recombination)



实值重组产生子个体般是用下边这个算法:
子个体=父个体1 + a × ( 父个体2 - 父个体1 )
这里a是个比例因子可以由[ -d, 1+d] 上边服从均匀分布随机数产生
区别重组算法a取值是区别般来讲d=0.25是个比较好选择
下边段c代码片断实现个中值重组算法其中d取值为0

1 /*
2 Gene Crossover Algorithm
3 Linear Recombination Xover Algorithm
4
5 A crossover operator that linearly combines two parent
6 chromosome vectors to produce two offspring a
7 ccording to the following equations:
8
9 Offspring1 = a * Parent1 + (1- a) * Parent2
10 Offspring2 = (1 – a) * Parent1 + a * Parent2
11
12
13 where a is a random weighting factor (chosen before each
14 crossover operation).
15
16 Consider the following 2 parents (each consisting of 4
17 float genes) which have been selected for crossover:
18
19 Parent 1: (0.3)(1.4)(0.2)(7.4)
20 Parent 2: (0.5)(4.5)(0.1)(5.6)
21
22 If a = 0.7, the following two offspring would be produced:
23
24 Offspring1: (0.36)(2.33)(0.17)(6.86)
25 Offspring2: (0.402)(2.981)(0.149)(6.842)
26 */
27 template< GENE >
28 Intermediate_Recombination_Gene_Crossover_Algorithm
29 {
30 public:
31 void operator( GENE& g1, GENE& g2 )const
32 {
33 assert( g1.Upper g2.Upper );
34 assert( g1.Lower g2.Lower );
35
36 const long double Ran = ran;
37 const long double sum = g1.Value + g2.Value;
38
39 ( sum < g1.Upper )
40 {
41 g1.Value = Ran * sum;
42 g2.Value = sum - g1.Value;
43 }
44
45 {
46 const long double sub = 2.0L * g1.Upper - sum;
47 g1.Value = g1.Upper - sub * Ran;
48 g2.Value = g1.Upper - sub + sub * Ran;
49 }
50 }
51 };
Tags:  排序算法 算法导论 加密算法 recombination

延伸阅读

最新评论

发表评论