Learn R Programming

CEGO (version 2.1.0)

optimEA: Evolutionary Algorithm for Combinatorial Optimization

Description

A basic implementation of a simple Evolutionary Algorithm for Combinatorial Optimization. Default evolutionary operators aim at permutation optimization problems.

Usage

optimEA(x = NULL, fun, control = list())

Arguments

x

Optional start individual(s) as a list. If NULL (default), creationFunction (in control list) is used to create initial design. If x has less individuals than the population size, creationFunction will fill up the rest.

fun

target function to be minimized

control

(list), with the options budget The limit on number of target function evaluations (stopping criterion) (default: 1000) popsize Population size (default: 100) generations Number of generations (stopping criterion) (default: Inf) targetY Target function value (stopping criterion) (default: -Inf) vectorized Boolean. Defines whether target function is vectorized (takes a list of solutions as argument) or not (takes single solution as argument). Default: FALSE verbosity Level of text output during run. Defaults to 0, no output. plotting Plot optimization progress during run (TRUE) or not (FALSE). Default is FALSE. archive Whether to keep all candidate solutions and their fitness in an archive (TRUE) or not (FALSE). Default is TRUE. recombinationFunction Function that performs recombination, default: recombinationPermutationCycleCrossover, which is cycle crossover for permutations. recombinationParameters Parameter list for recombination (e.g., recombinationParameters$recombinationRate => recombination rate, defaults to 0.5). List is passed to recombinationFunction. mutationFunction Function that performs mutation, default: mutationPermutationSwap, which is swap mutation for permutations. mutationParameters Parameter list for mutation (e.g., mutationParameters$mutationRate => mutation rate). List is passed to mutationFunction. Default: empty list. selection Selection process: "tournament" (default) or "truncation" tournamentSize Tournament size (default: 2) tournamentProbability Tournament probability (default: 0.9) localSearchFunction If specified, this function is used for a local search step. Default is NULL. localSearchRate Specifies on what fraction of the population local search is applied. Default is zero. Maximum is 1 (100 percent). localSearchSettings List of settings passed to the local search function control parameter. stoppingCriterionFunction Custom additional stopping criterion. Function evaluated on the population, receiving all individuals (list) and their fitness (vector). If the result is FALSE, the algorithm stops. verbosity >0 for text output. creationFunction Function to create individuals/solutions in search space. Default is a function that creates random permutations of length 6 duplicateFunction Function that evaluates a list of solutions for duplicates. Default is the duplicated function. duplicateRemoval If set to "all" and archiving is on, new individuals are compared against the complete archive to avoid duplicates. With "population", this is limited to the current population.

Value

a list: xbest best solution found ybest fitness of the best solution x history of all evaluated solutions y corresponding target function values f(x) count number of performed target function evaluations message Termination message: Which stopping criterion was reached. population Last population fitness Fitness of last population

See Also

optimCEGO, optimRS, optim2Opt, optimMaxMinDist

Examples

Run this code
# NOT RUN {
seed=0
#distance
dF <- distancePermutationHamming
#mutation
mF <- mutationPermutationSwap
#recombination
rF <-  recombinationPermutationCycleCrossover 
#creation
cF <- function()sample(5)
#objective function
lF <- landscapeGeneratorUNI(1:5,dF)
#start optimization
set.seed(seed)
res <- optimEA(,lF,list(creationFunction=cF,mutationFunction=mF,recombinationFunction=rF,
	popsize=15,budget=100,targetY=0,verbosity=1,
	vectorized=TRUE)) ##target function is "vectorized", expects list as input
res$xbest 

# }

Run the code above in your browser using DataLab