'BLX-alpha crossover: what approach is the right one?
I'm working on genetic algorithm which uses blend BLX-alpha crossover.
I found 2 algorithms, which seem to me quite different from each other
- https://yadi.sk/i/u5nq986GuDoNm - page 8
crossover is made as follows:
a. Select 2 parents: G1, G2
b. generate uniformly distributed random number gamma from [-alpha, 1 + alpha], where alpha = 0.5
c. generate an offspring as follows: G = gamma * G1 + (1 - gamma) * G2 http://www.tomaszgwiazda.com/blendX.htm
crossover is made as follows:
a. select two parents X(t) and Y(t) from a parent poolb. create two offspring X(t+1) and Y(t+1) as follows:
c. for i = 1 to n do
d. di=|xi(t)-yi(t)|
e. choose a uniform random real number u from interval
f. xi(t+1)=u
g. choose a uniform random real number u from interval
h. yi(t+1)=u
i. end do
where:
a – positive real parameter
xi, yi - the i-th component of a parent
di - distance betweet parent components
Which of these 2 algorithms is correct? Or they are equal? In my task I'm using 2nd method, because the first one provides unsatisfying results. I concerned with this question, because I'm working on GA, where the first algorithm is supposed to be used.
Any help would be appreciated!
Solution 1:[1]
You can search for paper "Real-Coded Genetic Algorithms and Interval Schemata" in which the BLX-alpha crossover first introduced.
In this paper,the first algorithm is introduced.
As for the second one ,I think it is equal to the first one in the way of producing offsprings.Because the second algs produces two offsprings one time,it has more chance to get a better individual.But it also needs more FEs.
Solution 2:[2]
def crossover_blen(p1,p2,alpha):
c1,c2 = deepcopy(p1),deepcopy(p2)
for i in range(len(p1)):
distancia = abs(c2[i]-c1[i])
l = min(c1[i],c2[i]) - alpha * distancia
u = max(c1[i],c2[i]) + alpha * distancia
c1[i] = l + random.random() * (u-l)
c2[i] = l + random.random() * (u-l)
return [c1,c2]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kevin Yang |
Solution 2 | bguiz |