Provides the functions of the Genetic Algorithm Toolbox for 'MATLAB' developed at the University of Sheffield (Chipperfield et al. 1994, < https://github.com/UoS-CODeM/GA-Toolbox>), rewritten in R. It includes operators for creating binary, integer and real-valued populations, rank-based and linear fitness assignment, roulette wheel and stochastic universal sampling selection, single-point, multi-point, shuffle and reduced surrogate crossover, discrete, intermediate and line recombination, discrete and breeder genetic algorithm mutation, reinsertion of offspring, and migration between subpopulations.
# gatbxr
Genetic Algorithm Toolbox for R, ported from the Sheffield Genetic Algorithm Toolbox for MATLAB.
gatbxr provides operators for creating populations, fitness assignment, selection, crossover, recombination, mutation, reinsertion and migration between subpopulations for binary, integer and real-valued representations.
Install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("drizztxx/gatbxr")
library(gatbxr)
## Minimise the sphere function in 10 dimensions
objfun <- function(Phen) rowSums(Phen^2)
FieldD <- list(prec = 20, lb = -512, ub = 512, code = "gray",
scale = "arith", lbin = TRUE, ubin = TRUE)
Chrom <- crtbp(40, 10 * 20)$Chrom
ObjV <- objfun(bs2rv(Chrom, FieldD))
for (gen in 1:100) {
FitnV <- ranking(ObjV)
SelCh <- select("sus", Chrom, FitnV, GGAP = 0.9)
SelCh <- recombin("xovsp", SelCh)
SelCh <- mutate("mut", SelCh)
ObjVSel <- objfun(bs2rv(SelCh, FieldD))
res <- reins(Chrom, SelCh, 1, c(1, 1), ObjV, ObjVSel)
Chrom <- res$Chrom
ObjV <- res$ObjVCh
}
min(ObjV)
The Genetic Algorithm Toolbox for MATLAB was developed at the Department of Automatic Control and Systems Engineering of The University of Sheffield, UK, in order to make GAs accessible to the control engineer within the framework of an existing computer-aided control system design package. The toolbox was written with the support of a UK SERC grant, and the final version (v1.2) was completed in 1994. It was written by Andrew Chipperfield, Peter Fleming, Hartmut Pohlheim and Carlos Fonseca.
The original toolbox is copyright the original authors and The University of Sheffield, and is published under the GNU General Public License. As a derived work, gatbxr is also distributed under the GNU General Public License (version 2 or later).