# Documentation of compete

Global Index (all files) (short | long) | Local contents | Local Index (files in subdir) (short | long)

## Function Synopsis

`[NewChrom, NewObjV, SubPop, CompQuality, TestVars] = compete(Chrom, SubPop, CompQuality, CompOpt, ObjV, FitnV);`

## Help text

``` COMPETition between subpopulations

This function performs competition between subpopulations.
The division of the individuals to the subpopulations can be
controlled by one parameter - the division pressure. The
effect of this parameter is identical to selection pressure
(even the same functions are used for calculation). Instead
of using individuals here we use subpopulations.
The selection of the individuals for transfer to other
(better) subpopulations can be chosen between:
- uniform at random selection
- fitness-based selection
For fitness-based competition (worst individuals are deleted)
the fitness values/ranking of the population (FitnV) is needed.
If omitted or empty single objective scaling using the first
column of the objective values (ObjV) is assumed.
If the objective values of the population (ObjV) are input
parameter and ObjV is output parameter the objective values
are copied, according to the flowing of individuals, saving
the recomputation of the objective values for the whole popu-
lation.
The function can handle multiple objective values per individual.

Syntax:  [NewChrom, NewObjV, SUBPOP, CompQuality] = compete(Chrom, SUBPOP, CompQuality, CompOpt, ObjV, FitnV)

Input parameters:
Chrom     - Matrix containing the individuals of the current
population. Each row corresponds to one individual.
SubPop    - Vector/scalar containing number of individuals per
subpopulation/number of subpopulations
if omitted or NaN, 1 subpopulation is assumed
CompQuality - Vector containing the competition quality of each
subpopulation (output parameter of this function)
if omitted, NaN or empty, CompQuality is calculated
equivalent to the size of each subpopulation
CompOpt   - (optional) Vector containing competition paremeters
CompOpt(1): CompRate - Rate of individuals to be deleted/
included per subpopulation (% of subpopulation)
if omitted or NaN, 0.2 (20%) is assumed
CompOpt(2): Select - number indicating the selection method
of deleting individuals
0 - uniform selection
1 - fitness-based selection (worst individuals are deleted)
if omitted or NaN, 1 is assumed
CompOpt(3): CompMin - number indicating the minimal number of
individuals in a subpopulation
if omitted or NaN, 5 is assumed
CompOpt(4): DivisionPressure (analog to selective pressure)
can be given in the range: 1 - (NumSubPop-2)
1: no division pressure (not really useful)
2: the best subpop receives twice as many individuals
as the mean of all subpops
max value (for instance 4, when using 6 subpops): the
best subpop gets 4 times as many individuals ...
(this means nearly 50% of the individuals)
(maximal 2 for linear division)
if omitted or NaN, 2 is assumed
CompOpt(5): for test purpose only
NaN: automatically selected
(DivisionPressure <=2: linear division,
else non-linear)
1: lin. division function
2: nonlin. division function
ObjV      - Column vector or matrix containing the objective values
of the individuals in the current population,
if Rank is omitted, first column is used for
fitness-based competition, saves recalculation
of objective values for population
FitnV     - (optional) Column vector containing the fitness
values of the individuals
in the current population, best individual has
highest value,
if omitted or empty, single objective scaling
using first column of ObjV is assumed

Output parameters:
NewChrom  - Matrix containing the individuals of the current
population after competition.
NewObjV   - (optional) Column vector containing the objective
values of the individuals of the current generation
after competition.
SubPop    - (optional) Vector/scalar containing number of indi-
viduals per subpopulation/number of subpopulations
after competition