# crowdingDist4frnt: Crowding Distance Assignment for Each Front In nsga2R: Elitist Non-dominated Sorting Genetic Algorithm based on R

## 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

 `1` ```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 [email protected]

## 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

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22``` ```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 ```

### Example output

```Loading required package: mco
[,1]        [,2]
[1,] 0.41245563 0.556704046
[2,] 0.54997118 0.150408692
[3,]        Inf         Inf
[4,]        Inf         Inf
[5,]        Inf         Inf
[6,] 0.28517166 0.096729285
[7,]        Inf         Inf
[8,] 0.23600667 0.116778673
[9,] 0.47031020 0.165925432
[10,]        Inf         Inf
[11,]        Inf         Inf
[12,]        Inf         Inf
[13,]        Inf         Inf
[14,]        Inf         Inf
[15,]        Inf         Inf
[16,] 0.04878401 0.201568249
[17,]        Inf         Inf
[18,]        Inf         Inf
[19,]        Inf         Inf
[20,] 0.35098612 0.159272402
[21,]        Inf         Inf
[22,]        Inf         Inf
[23,] 0.07707297 0.088479642
[24,]        Inf         Inf
[25,]        Inf         Inf
[26,] 0.27527599 0.038910564
[27,]        Inf         Inf
[28,] 0.51850755 0.133768131
[29,]        Inf         Inf
[30,]        Inf         Inf
[31,] 0.46746309 0.254187310
[32,] 0.05600950 0.250167076
[33,]        Inf         Inf
[34,] 0.34858104 0.058799059
[35,] 0.02153579 0.043067540
[36,] 0.29520905 0.340772345
[37,]        Inf         Inf
[38,]        Inf         Inf
[39,] 0.58792481 0.379853435
[40,] 0.66101314 0.504217249
[41,] 0.25168663 0.009080377
[42,]        Inf         Inf
[43,] 0.40720827 0.187183273
[44,] 0.03955123 0.039279512
[45,] 0.17315247 0.571172687
[46,] 0.16715599 0.110014689
[47,] 0.25743651 0.210516421
[48,] 0.16766024 0.135300547
[49,]        Inf         Inf
[50,]        Inf         Inf
```

nsga2R documentation built on May 29, 2017, 8:02 p.m.