Learn R Programming

mcga (version 3.0.7)

mcga2: Performs a machine-coded genetic algorithm search for a given optimization problem

Description

mcga2 is the improvement version of the standard mcga function as it is based on the GA::ga function. The byte_crossover and the byte_mutation operators are the main reproduction operators and these operators uses the byte representations of parents in the computer memory.

Usage

mcga2(fitness, ..., min, max,
  population = gaControl("real-valued")$population,
  selection = gaControl("real-valued")$selection,
  crossover = byte_crossover, mutation = byte_mutation, popSize = 50,
  pcrossover = 0.8, pmutation = 0.1, elitism = base::max(1, round(popSize
  * 0.05)), maxiter = 100, run = maxiter, maxFitness = Inf,
  names = NULL, parallel = FALSE, monitor = gaMonitor, seed = NULL)

Value

Returns an object of class ga-class

Arguments

fitness

The goal function to be maximized

...

Additional arguments to be passed to the fitness function

min

Vector of lower bounds of variables

max

Vector of upper bounds of variables

population

Initial population. It is gaControl("real-valued")$population by default.

selection

Selection operator. It is gaControl("real-valued")$selection by default.

crossover

Crossover operator. It is byte_crossover by default.

mutation

Mutation operator. It is byte_mutation by default. Other values can be given including byte_mutation_random, byte_mutation_dynamic and byte_mutation_random_dynamic

popSize

Population size. It is 50 by default

pcrossover

Probability of crossover. It is 0.8 by default

pmutation

Probability of mutation. It is 0.1 by default

elitism

Number of elitist solutions. It is base::max(1, round(popSize*0.05)) by default

maxiter

Maximum number of generations. It is 100 by default

run

The genetic search is stopped if the best solution has not any improvements in last run generations. By default it is maxiter

maxFitness

Upper bound of the fitness function. By default it is Inf

names

Vector of names of the variables. By default it is NULL

parallel

If TRUE, fitness calculations are performed parallel. It is FALSE by default

monitor

The monitoring function for printing some information about the current state of the genetic search. It is gaMonitor by default

seed

The seed for random number generating. It is NULL by default

Author

Mehmet Hakan Satman - mhsatman@istanbul.edu.tr

References

M.H.Satman (2013), Machine Coded Genetic Algorithms for Real Parameter Optimization Problems, Gazi University Journal of Science, Vol 26, No 1, pp. 85-95

Luca Scrucca (2013). GA: A Package for Genetic Algorithms in R. Journal of Statistical Software, 53(4), 1-37.

See Also

GA::ga

Examples

Run this code
f <- function(x){ 
  return(-sum( (x-5)^2 ) )
}
myga <- mcga2(fitness = f, popSize = 100, maxiter = 300, 
              min = rep(-50,5), max = rep(50,5))
print(myga@solution)

Run the code above in your browser using DataLab