# crowdingDist4frnt: Crowding Distance Assignment for Each Front In nsga2R: Elitist Non-Dominated Sorting Genetic Algorithm

 crowdingDist4frnt R Documentation

## Crowding Distance Assignment for Each Front

### Description

This function estimates the density of solutions surrounding a particular solution within each front. It calculates the crowding distances of solutions according to their objectives and those within the same front.

### Usage

```crowdingDist4frnt(pop, rnk, rng)
```

### Arguments

 `pop` Population matrix including decision variables, objective functions, and nondomination rank `rnk` List of solution indices for each front `rng` Vector of each objective function range, i.e. the difference between the maximum and minimum objective function value of each objective

### Value

Return a matrix of crowding distances of all solutions

### Author(s)

Ching-Shih (Vince) Tsou cstsou@mail.ntcb.edu.tw

### References

Deb, K., Pratap, A., Agarwal, S., and Meyarivan, T. (2002), " A fast and elitist multiobjective genetic algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, 6(2), 182-197.

`fastNonDominatedSorting`

### Examples

```library(mco)
popSize <- 50
lowerBounds <- rep(0,30)
upperBounds <- rep(1,30)
varNo <- length(lowerBounds)
objDim <- 2
set.seed(1234)
population <- t(sapply(1:popSize, function(u) array(runif(length(lowerBounds),
lowerBounds,upperBounds))))
population <- cbind(population, t(apply(population,1,zdt2)))
ranking <- fastNonDominatedSorting(population[,(varNo+1):(varNo+objDim)])
rnkIndex <- integer(popSize)
i <- 1
while (i <= length(ranking)) {
rnkIndex[ranking[[i]]] <- i
i <- i + 1
}
population <- cbind(population,rnkIndex)
objRange <- apply(population[,(varNo+1):(varNo+objDim)], 2, max) -
apply(population[,(varNo+1):(varNo+objDim)], 2, min)
cd <- crowdingDist4frnt(population,ranking,objRange)
cd
```

nsga2R documentation built on May 23, 2022, 5:06 p.m.