Skip to content

Commit f799808

Browse files
committed
parent centric xover: eliminate eye matrix alloc
1 parent 363312e commit f799808

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/genetic_operators/crossover/parent_centric_crossover.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ function apply!{NP}(xover::ParentCentricCrossover{NP}, target::Individual, targe
2929
broadcast!(-, parents_centered, parents_centered, center)
3030
# project other parents vectors orthogonal to
3131
# the subspace orthogonal to the selected parent
32-
other_parents_centered = (eye(size(parents_centered,1)) -
33-
A_mul_Bt(view(parents_centered, :, 1), view(parents_centered, :, 1))) *
32+
tmp_mtx = A_mul_Bt(view(parents_centered, :, 1), view(parents_centered, :, 1))
33+
@inbounds for i in 1:size(tmp_mtx, 1)
34+
tmp_mtx[i,i] -= 1.0
35+
end
36+
other_parents_centered = tmp_mtx *
3437
view(parents_centered, :, 2:length(parentIndices))
3538
sd = mean(map(sqrt, sumabs2(other_parents_centered, 2)))
3639
if sd > 1E-8

0 commit comments

Comments
 (0)