adana {adana}R Documentation

Adaptive Nature-inspired Algorithms for Hybrid Genetic Optimization

Description

The adana function is a GA function that can be used for any single-objective optimization problem.

Usage

adana(gatype = "gga", objective = "max", maxiter = 100, initfunc = initbin, fitfunc,
      selfunc = seltour, crossfunc = px1, mutfunc = bitmut, replace = elitism,
      adapfunc = NULL, hgafunc = NULL, monitorfunc = NULL, n = 100, m = 8,
      lb = rep(0, 8), ub = rep(1, 8), nmode = "real", type = 1, permset = 0:9,
      prevpop = NULL, selt = 2, selbc = 0.5, selc = 2, selk = 1.005, sells = 1.5,
      selns = 0.5, selps = 0.5, sels = 1.5, selt0 = 50, selw = 2, reptype = FALSE,
      cxpc = 0.9, cxpc2 = 0.8, cxon = 2, cxk = 2, cxps = 0.5, cxa = 0, cxb = 0.15,
      cxealfa = 1, cxalfa = 0.5, mutpm = 0.05, mutpm2 = 0.2, mutb = 2, mutpow = 2,
      mutq = 0.5, mutmy = c(), mutsdy = c(), adapa = 0.75, adapb = 0.5, adapc = 0.1,
      adapd = 0.1, hgastep = 10, hgans = 1, hgaftype = "w", reps = 1, repk = 10,
      lambda = 1, tercrit = c(1), abdif = 1e-06, bestdif = 1e-06, objval = 0,
      optdif = 1e-06, rmcnt = 10, rmdif = 1e-06, phidif = 1e-06, rangedif = 1e-06,
      meandif = 1e-06, sddif = 1e-06, mincv = 0.001, simlev = 0.95, maxtime = 60,
      keepbest = TRUE, parfile = NULL, verbose = FALSE, ...)

Arguments

gatype

Type of GA.

  • "gga": generational GA

  • "ssga": steady state GA

Default value is "gga"

objective

Type of optimization.

  • "min": minimization

  • "max": maximization

Default value is "max"

maxiter

Maximum generation number

Default value is 100

initfunc

Name of fitness function.

  • "initbin" : for binary-coded

  • "initval" : for value-coded

  • "initperm": for permutation-coded

  • or user-defined initialize function

Default value is "initbin"

fitfunc

Fitness function

selfunc

Name of the selection function

Default value is "seltour"

crossfunc

Name of the crossover function

Default value is "px1"

mutfunc

Name of the mutation function

Default value is "bitmut"

replace

Name of the replacement function

Default value is "elitism"

adapfunc

Name of the adaptation function

hgafunc

The name of the function that will do the hybridization.

monitorfunc

Monitoring function

n

Population size

m

Length of chromosome

lb

A vector containing lower bounds for variables in value-coded problems

ub

A vector containing upper bounds for variables in value-coded problems

nmode

Value mode for initiating value-coding problems

  • "integer"

  • "real"

Default value is "real"

type

Integer indicating the type of initialization matrix.

  • 1 : contains the chromosome, fitness value and generation number.

  • 2 : contains only the chromosome.

permset

A vector containing the ordinal values to be used in permutation-coded initialization.

Default value is 0:9

prevpop

A matrix containing previously prepared chromosomes during initialization.

selt

The tournament size for the seltour and seltour2 functions.

Default value is 2.

selbc

The base parameter for the selers function.

Default value is 0.5.

selc

Scale parameter for selsscale and selsscale2 functions

Default value is 2.

selk

Power parameter for selpscale function

Default value is 1.005.

sells

Scale parameter for sellscale function

Default value is 1.5.

selns

Polynomal coefficient for selnlrs function

Default value is 0.5.

selps

Cut-point threshold value for seltrunc function.

Default value is 0.5.

sels

Selection pressure for sellrs, sellrs3 and selrscale2 functions.

Default value is 1.5.

selt0

The starting temperature for selboltour function.

Default value is 50.

selw

Window size for selwscale function.

Default value is 2.

reptype

TRUE value is entered for the sampling with replacement when the seltour and seltour2 are used.

Default value is FALSE.

cxpc

Crossover ratio

Default value is 0.9.

cxpc2

Adapted crossover ratio for the leitingzhi function.

cxon

Number of offspring per mating in crossover.

Default value is 2.

cxk

Number of cut-points for multi-point crossover.

Default value is 2.

cxps

Probability threshold value for hux, ux, ux2, dc crossovers.

Default value is 0.5.

cxa

Location Parameter for lapx crossover

Default value is 0.

cxb

Scale Parameter for lapx crossover

Default value is 0.15

cxealfa

The random alpha value for sax, wax, ebx crosses. It is determined dynamically, but for some controlled studies, a fixed value can be assigned.

cxalfa

The random alpha value for sax, wax, ebx crosses. It is determined dynamically, but for some controlled studies, a fixed value can be assigned.

mutpm

Mutation rate

Default value is 0.05

mutpm2

Adaptive mutation rate

mutb

The exponent value used to avoid uniformity in unimut and nunimut2.

Default value is 0.5

mutpow

The exponent value for powmut and powmut2 functions.

Default value is 2.

mutq

A number. Value of q for bsearchmut1

Default value is 0.5

mutmy

A vector. Vector of means of genes

mutsdy

A vector. Vector of standard deviations of genes

adapa

Adaptation threshold a for leitingzhi function

Default value is 0.5

adapb

Adaptation threshold b for leitingzhi function

Default value is 0.75

adapc

Crossover adaptation threshold for adana3 function

Default value is 0.2

adapd

Mutation adaptation threshold for adana3 function

Default value is 0.05

hgastep

In a hybrid GA implementation, it is an integer indicating how many generations the hybrid optimization algorithm will be called.

Default value is 10

hgans

Number of individuals to be transferred to the Optim.

Default value is 2

hgaftype

Types of fitness to transfer.

  • w: individuals with the worst fitness value

  • b: individuals with the best fitness value

  • r: randomly selected individuals

Default value is "w"

reps

The number of the best individuals to be selected when elitism is applied.

Default value is 1.

repk

The selection pressure parameter for the Round Robin function.

Default value is 10.

lambda

Total number of offspring in replacement algorithms in steady-state replacement type GAs

Default value is 1.

tercrit

A vector for termination criterion

Default value is (1,13).

abdif

It is an approach difference value used by the termination criterion 6.

Default value is 1e-06.

bestdif

The approach value to the global optimum value.

Default value is 1e-06.

objval

Global optimum. Used by some termination criterion. This criterion is used if the global optimum of the problem is known.

optdif

It is an approach difference value used by the termination criterion 3.

Default value is 1e-06.

rmcnt

k value used by the termination criterion 5.

Default value is 10.

rmdif

It is an approach difference value used by the termination criterion 5.

Default value is 1e-06.

phidif

It is an approach difference value used by the termination criterion 10.

Default value is 1e-06.

rangedif

It is an approach difference value used by the termination criterion 8.

Default value is 1e-06.

meandif

It is an approach difference value used by the termination criterion 4.

Default value is 1e-06.

sddif

It is an approach difference value used by the termination criterion 7.

Default value is 1e-06.

mincv

Minimum coefficient of variance used by the termination criterion 9.

Default value is 0.001.

simlev

It is an approach difference value used by the termination criterion 7.

Default value is 0.99.

maxtime

It is maximum runtime (minute) value used by the termination criterion 12.

Default value is 60.

keepbest

If the keepbest parameter is TRUE, the best solution value, chromosome, and generation number are saved in the list named bestsol.

Default value is TRUE.

parfile

The name of the file where the parameter values are defined if any.

Default value is NULL.

verbose

TRUE is assigned to display the statistics of fitness values obtained at the end of the loop in the GA study.

Default value is FALSE.

...

additional arguments to be passed to the initialize, select, cross, mutate, hgafunc, and show functions.

Details

adana function is a genetic algorithm function that can be used for all kinds of single-objective optimization problems. The adana function, unlike other GA packages, not only has adaptive GA functions, but also offers specially developed deterministic and self-adaptive techniques called adana1, adana2, and adana3, and is easily hybridized with other optimization methods inspired by nature. Besides, the adana function supports the use of monitors to monitor the progress of the GA run. In addition to containing many crossover and mutation operators, it is coded with a plug-and-play approach so that the user can add custom operator functions that he has developed.

The initialization population is created by using the name of the initialization function and other parameters passed to initfunc with the initialize function. The fit values of individuals in the population are calculated using fitfunc, which is passed to the evaluate function before each iteration. Then, the termination conditions are checked according to the criteria specified in the termination criteria (tercrit) argument via the terminate function. When the termination condition is not met, adana GA continues to run and searches for the best solution. If the keepbest argument is TRUE, the best solution value, chromosome, and generation number are saved in the list named bestsol.

Since the adana function allows adaptive GA studies, from which it is named, it runs a function that is passed with the adapfunc argument and contains the code of the adaptation algorithm. This adaptation function returns the crossover and mutation rates by recalculating. Thus, it strengthens the GA with its exploitation and exploration adaptations.

In order to determine the individuals to be selected for the mating pool, the selection process is done with the selfunc selection function transferred to the select function.

The crossover of selected individuals is executed with the crossover operator in the crossfunc argument passed to the cross function.

Mutation operations are performed with the mutation operator function assigned to mutfunc by the mutate function.

Finally, for GA, replacement is performed by passing the parent population and the offspring population to the replace function.

Hybridization with other optimization techniques can also be done before an iteration of the GA is complete. For this, the hybridization function passed to the hgafunc argument is used. Other parameters that need the optimization technique called in the hybridization function call, are also passed.

Progress made in each GA generation can be monitored visually with a monitor function. For this, the monitor function passed to the monitorfunc argument is used.

In GA implementations, if the required parameters for R functions that perform selection, crossover, mutation, renewal, and other operations are not entered in the function call, their default values are used. The user can change these parameters during the function call to suit the problem. However, there are many parameters used by the adana function and the functions it calls. It may be more practical to use the parameters by saving them to a file. The parfile argument can be used for this purpose.

Value

genfits

A matrix containing statistics for generations.

initpop

A matrix containing the initial population

finalpop

A matrix containing the final population

bestsol

Value of the best solution

objective

Objective of the optimization, min or max

tcode

Termination code

Author(s)

Zeynel Cebeci & Erkut Tekeli

References

Cebeci, Z. (2021). R ile Genetik Algoritmalar ve Optimizasyon Uygulamalari, 535 p. Ankara:Nobel Akademik Yayincilik.

See Also

GA Operators: initialize, evaluate, terminate, select, cross, mutate

Initialize Functions: initbin, initval, initperm, initnorm

Selection Functions: selrand, selrswrp, selrws, selrws2, selrss, selsus, seldet, selwscale, selsscale, selsscale2, sellscale, selrscale, selrscale2, selpscale, selescale, seltour, seltour2, selboltour, sellrs, sellrs2, sellrs3, selnlrs, selers, seltrunc

Crossover Functions: px1, kpx, sc, rsc, hux, ux, ux2, mx, rrc, disc, atc, cpc, eclc, raoc, dc, ax, hc, sax, wax, lax, bx, ebx, blxa, blxab, lapx, elx, geomx, spherex, pmx, mpmx, upmx, ox, ox2, mpx, erx, pbx, pbx2, cx, icx, smc

Mutation Functions: bitmut, randmut, randmut2, randmut3, randmut4, unimut, boundmut, nunimut, nunimut2, powmut, powmut2, gaussmut, gaussmut2, gaussmut3, bsearchmut1, bsearchmut2, swapmut, invmut, shufmut, insmut, dismut, invswapmut, insswapmut, invdismut

Replacement Functions: grdelall, elitism, grmuplambda, grmuplambda2, grmuplambda3, grmuplambda4, grmuvlambda, grrobin, ssrmup1, ssrmup1, ssrgenitor, ssrfamtour, ssrx

Adaptation Functions: fixpcmut, ilmdhc, adana1, adana2, adana3, leitingzhi

Hybridization Functions: hgaoptim, hgaoptimx, hgaroi

Examples

# Preparing data
material = c("knife", "tin", "potato", "coffee", "sleeping bag", "rope", "compass")
weigth = c(1, 5, 10, 1, 7, 5, 1)
point = c(10, 20, 15, 2, 30, 10, 30)
kspdata = data.frame(material, weigth, point)
capacity = 100

# Fitness Function
kspfit2 = function(x, ...) {
  tpoint = x %*% kspdata$point
  tweigth = x %*% kspdata$weigth
  G1 = tweigth-capacity 
  fitval = tpoint-max(0,G1)^2     
  return(fitval)
}

# Run GA
n = 20
m = nrow(kspdata)
niter = 100
kspGGA = adana(n=n, m=m, maxiter=niter, objective="max", gatype="gga",
  initfunc=initbin, fitfunc=kspfit2, selfunc=seltour, 
  crossfunc=kpx, mutfunc=bitmut, replace=elitism,
  selt=2, reps=4, repk=5, cxon=2, cxk=3, cxpc=0.8, 
  mutpm=0.05, tercrit=c(1), keepbest=TRUE,
  verbose=TRUE, monitorfunc=monprogress)
  
head(kspGGA$finalpop)        # Display Final Population
head(kspGGA$genfits)         # Display Fitness Values According to Generations
bestsol(kspGGA)              # Display Best Solution  
kspdata[kspGGA$bestsol$chromosome == 1, ]    # Display Best Chromosome

[Package adana version 1.1.0 Index]