nsga3: Non-Dominated Sorting in Genetic Algorithms III

View source: R/nsga3.R

nsga3R Documentation

Non-Dominated Sorting in Genetic Algorithms III


Minimization of a fitness function using non-dominated sorting genetic algorithms - III (NSGA-IIIs). Multiobjective evolutionary algorithms


  type = c("binary", "real-valued", "permutation"),
  population = nsgaControl(type)$population,
  selection = nsgaControl(type)$selection,
  crossover = nsgaControl(type)$crossover,
  mutation = nsgaControl(type)$mutation,
  popSize = 50,
  nObj = ncol(fitness(matrix(10000, ncol = 100, nrow = 100))),
  pcrossover = 0.8,
  pmutation = 0.1,
  reference_dirs = generate_reference_points,
  maxiter = 100,
  run = maxiter,
  maxFitness = Inf,
  names = NULL,
  suggestions = NULL,
  monitor = if (interactive()) nsgaMonitor else FALSE,
  summary = FALSE,
  seed = NULL



the type of genetic algorithm to be run depending on the nature of decision variables. Possible values are:


for binary representations of decision variables.


for optimization problems where the decision variables are floating-point representations of real numbers.


for problems that involves reordering of a list of objects.


the fitness function, any allowable R function which takes as input an individual string representing a potential solution, and returns a numerical value describing its “fitness”.


additional arguments to be passed to the fitness function. This allows to write fitness functions that keep some variables fixed during the search


a vector of length equal to the decision variables providing the lower bounds of the search space in case of real-valued or permutation encoded optimizations.


a vector of length equal to the decision variables providing the upper bounds of the search space in case of real-valued or permutation encoded optimizations.


a value specifying the number of bits to be used in binary encoded optimizations.


an R function for randomly generating an initial population. See nsga_Population() for available functions.


an R function performing selection, i.e. a function which generates a new population of individuals from the current population probabilistically according to individual fitness. See nsga_Selection() for available functions.


an R function performing crossover, i.e. a function which forms offsprings by combining part of the genetic information from their parents. See nsga_Crossover() for available functions.


an R function performing mutation, i.e. a function which randomly alters the values of some genes in a parent chromosome. See nsga_Mutation() for available functions.


the population size.


number of objective in the fitness function.


Partition number of generated reference points


the probability of crossover between pairs of chromosomes. Typically this is a large value and by default is set to 0.8.


the probability of mutation in a parent chromosome. Usually mutation occurs with a small probability, and by default is set to 0.1.


Function to generate reference points using Das and Dennis approach or matrix with supplied reference points.


the maximum number of iterations to run before the NSGA search is halted.


the number of consecutive generations without any improvement in the best fitness value before the NSGA is stopped


the upper bound on the fitness function after that the NSGA search is interrupted.


a vector of character strings providing the names of decision variables.


a matrix of solutions strings to be included in the initial population. If provided the number of columns must match the number of decision variables.


a logical or an R function which takes as input the current state of the nsga-class object and show the evolution of the search. By default, for interactive sessions the function nsgaMonitor prints the average and best fitness values at each iteration. If set to plot these information are plotted on a graphical device. Other functions can be written by the user and supplied as argument. In non interactive sessions, by default monitor = FALSE so any output is suppressed.


If there will be a summary generation after generation.


an integer value containing the random number generator state. This argument can be used to replicate the results of a NSGA search. Note that if parallel computing is required, the doRNG package must be installed.


The Non-dominated genetic algorithms III is a meta-heuristic proposed by K. Deb and H. Jain in 2013. The purpose of the algorithms is to find an efficient way to optimize multi-objectives functions (more than three).


Returns an object of class nsga3-class. See nsga3 for a description of available slots information.


Francisco Benitez benitezfj94@gmail.com


K. Deb and H. Jain, "An Evolutionary Many-Objective Optimization Algorithm Using Reference-Point-Based Nondominated Sorting Approach, Part I: Solving Problems With Box Constraints," in IEEE Transactions on Evolutionary Computation, vol. 18, no. 4, pp. 577-601, Aug. 2014, doi: 10.1109/TEVC.2013.2281535.

Scrucca, L. (2017) On some extensions to 'GA' package: hybrid optimisation, parallelisation and islands evolution. The R Journal, 9/1, 187-206. doi: 10.32614/RJ-2017-008

See Also

nsga(), nsga2()


#Example 1
#Two Objectives - Real Valued
zdt1 <- function (x) {
 if (is.null(dim(x))) {
   x <- matrix(x, nrow = 1)
 n <- ncol(x)
 g <- 1 + rowSums(x[, 2:n, drop = FALSE]) * 9/(n - 1)
 return(cbind(x[, 1], g * (1 - sqrt(x[, 1]/g))))

#Not run
## Not run: 
result <- nsga3(type = "real-valued",
                fitness = zdt1,
                lower = c(0,0),
                upper = c(1,1),
                popSize = 100,
                n_partitions = 100,
                monitor = FALSE,
                maxiter = 500)

## End(Not run)

#Example 2
#Three Objectives - Real Valued
dtlz1 <- function (x, nobj = 3){
    if (is.null(dim(x))) {
        x <- matrix(x, 1)
    n <- ncol(x)
    y <- matrix(x[, 1:(nobj - 1)], nrow(x))
    z <- matrix(x[, nobj:n], nrow(x))
    g <- 100 * (n - nobj + 1 + rowSums((z - 0.5)^2 - cos(20 * pi * (z - 0.5))))
    tmp <- t(apply(y, 1, cumprod))
    tmp <- cbind(t(apply(tmp, 1, rev)), 1)
    tmp2 <- cbind(1, t(apply(1 - y, 1, rev)))
    f <- tmp * tmp2 * 0.5 * (1 + g)

#Not Run
## Not run: 
result <- nsga3(type = "real-valued",
                fitness = dtlz1,
                lower = c(0,0,0),
                upper = c(1,1,1),
                popSize = 92,
                n_partitions = 12,
                monitor = FALSE,
                maxiter = 500)

## End(Not run)

rmoo documentation built on Sept. 24, 2022, 9:05 a.m.