Skip to content

Commit 9ec56e6

Browse files
committed
fix Base.next() dropped in 1.0
1 parent e6ac0ee commit 9ec56e6

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/frequency_adaptation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ If the block is empty, it is repopulated.
5252
The methods are randomly shuffled each time the block is regenerated, since we need
5353
to know their effectiveness at every period of the optimization process.
5454
"""
55-
function Base.next(fa::FrequencyAdapter)
55+
function next(fa::FrequencyAdapter)
5656
if fa.block_pos > length(fa.block)
5757
fill_block!(fa)
5858
end

src/genetic_operators/operators_mixture.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@ function apply!(opmix::GeneticOperatorsMixture,
2525
apply!(op, v, target_index)
2626
end
2727

28-
function Base.next(opmix::FixedGeneticOperatorsMixture)
28+
"""
29+
next(fa::FixedGeneticOperatorsMixture)
30+
31+
Gets the random genetic operator from the mixture.
32+
33+
The probability to select an operator is proportional to its weight.
34+
35+
Returns a tuple of the genetic operator and its index in the mix.
36+
"""
37+
function next(opmix::FixedGeneticOperatorsMixture)
2938
i = sample(1:length(opmix.operators), opmix.weights)
3039
return opmix.operators[i], i
3140
end
@@ -47,7 +56,7 @@ end
4756

4857
frequencies(opmix::FAGeneticOperatorsMixture) = frequencies(opmix.fa)
4958

50-
function Base.next(opmix::FAGeneticOperatorsMixture)
59+
function next(opmix::FAGeneticOperatorsMixture)
5160
i = next(opmix.fa)
5261
return opmix.operators[i], i
5362
end

0 commit comments

Comments
 (0)