mcga2 {mcga} | R Documentation |
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)
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 |
selection |
Selection operator. It is |
crossover |
Crossover operator. It is |
mutation |
Mutation operator. It is |
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 |
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 |
maxFitness |
Upper bound of the fitness function. By default it is Inf |
names |
Vector of names of the variables. By default it is |
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 |
seed |
The seed for random number generating. It is |
Value
Returns an object of class ga-class
Author(s)
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
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)