ga_pmutation: Variable mutation probability in genetic algorithms

Description Usage Arguments Value Author(s) See Also Examples

Description

A function which calculates the mutation probability for the current iteration. This enables to use GAs with variable mutation rate (see examples).

Usage

1
ga_pmutation(object, p0 = 0.5, p = 0.01, T = round(object@maxiter/2), ...)

Arguments

object

An object of class "ga", usually resulting from a call to function ga.

p0

initial probability of mutation.

p

limiting probability of mutation.

T

maximum iteration after which it should converges to p.

...

Further arguments passed to or from other methods.

Value

Return a numeric value in the range (0,1).

Author(s)

Luca Scrucca

See Also

ga, ga_Mutation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
Rastrigin <- function(x1, x2)
{
  20 + x1^2 + x2^2 - 10*(cos(2*pi*x1) + cos(2*pi*x2))
}

GA <- ga(type = "real-valued", 
         fitness =  function(x) -Rastrigin(x[1], x[2]),
         lower = c(-5.12, -5.12), upper = c(5.12, 5.12), 
         popSize = 50, maxiter = 500, run = 100,
         pmutation = ga_pmutation)
plot(GA)

GA <- ga(type = "real-valued", 
         fitness =  function(x) -Rastrigin(x[1], x[2]),
         lower = c(-5.12, -5.12), upper = c(5.12, 5.12), 
         popSize = 50, maxiter = 500, run = 100,
         pmutation = function(...) ga_pmutation(..., p0 = 0.1))
plot(GA)

## End(Not run)

Example output

Loading required package: foreach
Loading required package: iterators
Package 'GA' version 3.2
Type 'citation("GA")' for citing this R package in publications.

Attaching package:GAThe following object is masked frompackage:utils:

    de

GA documentation built on May 2, 2019, 9:57 a.m.