Skip to content

Commit

Permalink
fix MutationWrapper (view -> viewer), add test
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Sep 21, 2016
1 parent 1ffa163 commit 52993b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/genetic_operators/crossover/mutation_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end

function apply!(wrapper::MutationWrapper, target::Individual, targetIndex::Int, pop, parentIndices)
@assert length(parentIndices) == 1
apply!(wrapper.inner, copy!(target, view(pop, parentIndices[1])), targetIndex)
apply!(wrapper.inner, copy!(target, viewer(pop, parentIndices[1])), targetIndex)
end

Base.show(io::IO, xover::MutationWrapper) = print(io, "MutationWrapper(", xover.inner, ")")
Expand Down
11 changes: 11 additions & 0 deletions test/test_crossover_operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,15 @@ context("DiffEvoRandBin1") do
end
end

context("MutationWrapper") do
ss = symmetric_search_space(2, (0.0, 10.0))
pop = reshape(collect(1.0:8.0), 2, 4)
gibbs = UniformMutation(ss)
gibbs_wrapper = BlackBoxOptim.MutationWrapper(gibbs)
@fact numchildren(gibbs_wrapper) --> 1
@fact numparents(gibbs_wrapper) --> 1
mut_res = BlackBoxOptim.apply!(gibbs_wrapper, [0.0, 0.0], 1, pop, [2])
@fact sum(mut_res .== BlackBoxOptim.viewer(pop, 2)) --> 0
end

end

0 comments on commit 52993b0

Please sign in to comment.