Skip to content

Commit

Permalink
fixed docs refs and kw parameter for older Julia versions
Browse files Browse the repository at this point in the history
  • Loading branch information
wildart committed Oct 30, 2021
1 parent 32df361 commit b925a2c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/src/crossover.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ Evolutionary.crosstree

[^5]: K. Deep, K. P. Singh, M. L. Kansal, and C. Mohan, "A real coded genetic algorithm for solving integer and mixed integer optimization problems.", Appl. Math. Comput. 212, 505-518, 2009

[^6] K. Deb, R. B. Agrawal, "Simulated Binary Crossover for Continuous Search Space", Complex Syst., 9., 1995
[^6]: K. Deb, R. B. Agrawal, "Simulated Binary Crossover for Continuous Search Space", Complex Syst., 9., 1995
2 changes: 1 addition & 1 deletion docs/src/mutation.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ shrink

[^8]: P. J. Angeline, "An investigation into the sensitivity of genetic programming to the frequency of leaf selection during subtree crossover", Genetic Programming 1996: Proceedings of the First Annual Conference, 21–29, 1996.

[^9] K. Deb, R. B. Agrawal, "Simulated Binary Crossover for Continuous Search Space", Complex Syst., 9., 1995
[^9]: K. Deb, R. B. Agrawal, "Simulated Binary Crossover for Continuous Search Space", Complex Syst., 9., 1995
2 changes: 1 addition & 1 deletion src/mutations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function PLM(Δ::Vector, η=2; pm::Real=NaN) # index of distribution p
end
return mutation
end
PLM(lower::Vector, upper::Vector, η::Real = 2; pm::Real=NaN) = PLM(upper-lower, η; pm)
PLM(lower::Vector, upper::Vector, η::Real = 2; pm::Real=NaN) = PLM(upper-lower, η; pm=pm)


# Combinatorial mutations (applicable to binary vectors)
Expand Down
9 changes: 5 additions & 4 deletions src/recombinations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,12 @@ function MILX(μ::Real = 0.0, b_real::Real = 0.15, b_int::Real = 0.35) # locatio
end

"""
LX(μ::Real = 0.0, b::Real = 0.2)
SBX(pm::Real = 0.5, η::Integer = 2)
Returns a Simulated Binary Crossover (SBX) recombination operation[^6], see [Recombination Interface](@ref).
Returns a Simulated Binary Crossover (SBX) recombination operation, see [Recombination Interface](@ref),
with the mutation probability `pm` of the recombinant component, and is the crossover distribution index `η`[^6].
"""
function SBX(p::Real = 0.5, η::Integer = 2)
function SBX(pm::Real = 0.5, η::Integer = 2)
function sbxv(v1::T, v2::T; rng::AbstractRNG=Random.GLOBAL_RNG) where {T <: AbstractVector}
n = length(v1)
u = rand(rng, n)
Expand All @@ -304,7 +305,7 @@ function SBX(p::Real = 0.5, η::Integer = 2)
μ = (v1 + v2)./2
diff = v1 - v2
c = β.*diff./2
mask_set = n == 1 ? [1] : rand(rng, n) .<= p
mask_set = n == 1 ? [1] : rand(rng, n) .<= pm
c1 = copy(μ) # c2 = μ - c
c1[mask_set] .-= c[mask_set]
c2 = copy(μ) # c2 = μ + c
Expand Down

0 comments on commit b925a2c

Please sign in to comment.