Skip to content

Commit

Permalink
parent centric xover: eliminate eye matrix alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Aug 19, 2016
1 parent 363312e commit f799808
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/genetic_operators/crossover/parent_centric_crossover.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ function apply!{NP}(xover::ParentCentricCrossover{NP}, target::Individual, targe
broadcast!(-, parents_centered, parents_centered, center)
# project other parents vectors orthogonal to
# the subspace orthogonal to the selected parent
other_parents_centered = (eye(size(parents_centered,1)) -
A_mul_Bt(view(parents_centered, :, 1), view(parents_centered, :, 1))) *
tmp_mtx = A_mul_Bt(view(parents_centered, :, 1), view(parents_centered, :, 1))
@inbounds for i in 1:size(tmp_mtx, 1)
tmp_mtx[i,i] -= 1.0
end
other_parents_centered = tmp_mtx *
view(parents_centered, :, 2:length(parentIndices))
sd = mean(map(sqrt, sumabs2(other_parents_centered, 2)))
if sd > 1E-8
Expand Down

0 comments on commit f799808

Please sign in to comment.