Skip to content

Commit

Permalink
rename matingPool to mating.pool
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed Mar 22, 2016
1 parent 093eeb4 commit 789a6cc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions R/doTheEvolution.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ doTheEvolution = function(task, control, initial.population = NULL) {
fireEvent("onEAInitialized", control, opt.state)

repeat {
matingPool = selectForMating(opt.state, control)
mating.pool = selectForMating(opt.state, control)
fireEvent("onMatingPoolGenerated", control, opt.state)

offspring = generateOffspring(opt.state, matingPool, control)
offspring = generateOffspring(opt.state, mating.pool, control)
offspring$fitness = evaluateFitness(offspring, task$fitness.fun, task, control)
fireEvent("onOffspringGenerated", control, opt.state)

Expand Down
12 changes: 6 additions & 6 deletions R/generateOffspring.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
#'
#' @param opt.state [\code{ecr_opt_state}]\cr
#' Optimization state.
#' @param matingPool [\code{ecr_population}]\cr
#' @param mating.pool [\code{ecr_population}]\cr
#' Mating pool to select individuals from.
#' @param control [\code{ecr_control}]\cr
#' Control object.
#' @return [\code{ecr_population}] Generated offspring.
#' @export
generateOffspring = function(opt.state, matingPool, control) {
generateOffspring = function(opt.state, mating.pool, control) {
n.offspring = control$n.offspring
task = opt.state$task
fitness.fun = task$fitness.fun
Expand All @@ -23,7 +23,7 @@ generateOffspring = function(opt.state, matingPool, control) {
i.offspring = 1L
while(i.offspring <= n.offspring) {
# select parents for mating
parents = getParents(matingPool, n.parents = getNumberOfParentsNeededForMating(control))
parents = getParents(mating.pool, n.parents = getNumberOfParentsNeededForMating(control))
children = recombine(parents, task, control)
# eventually the recombinator returns multiple children
if (hasAttributes(children, "multiple")) {
Expand All @@ -47,13 +47,13 @@ generateOffspring = function(opt.state, matingPool, control) {
# @title
# Helper method to extract two parents from the mating pool
#
# @param matingPool [\code{ecr_population}]
# @param mating.pool [\code{ecr_population}]
# Set of individuals selected for reproduction.
# @param n.parents [\code{integer(1)}]
# Number of individuals to select.
# @return [\code{list}]
getParents = function(matingPool, n.parents = 2L) {
inds = matingPool$individuals
getParents = function(mating.pool, n.parents = 2L) {
inds = mating.pool$individuals
n = length(inds)
# if we have only one individual, return it twice
if (n == 1L) {
Expand Down
4 changes: 2 additions & 2 deletions inst/examples/custom_ea_loop.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ opt.state = setupOptState(task, population, ctrl)
# now start the evolutionary cycle
repeat {
# first select some individuals for mating
matingPool = selectForMating(opt.state, ctrl)
mating.pool = selectForMating(opt.state, ctrl)

# then generate the offspring
offspring = generateOffspring(opt.state, matingPool, ctrl)
offspring = generateOffspring(opt.state, mating.pool, ctrl)
offspring$fitness = evaluateFitness(offspring, task$fitness.fun, task, ctrl)

# apply the survival selection
Expand Down
4 changes: 2 additions & 2 deletions man/generateOffspring.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 789a6cc

Please sign in to comment.