Package org.opt4j.operator.diversity
Class DiversityPermutation
java.lang.Object
org.opt4j.operator.diversity.DiversityPermutation
- All Implemented Interfaces:
Operator<PermutationGenotype<?>>
,Diversity<PermutationGenotype<?>>
The DiversityPermutation
is the interface for Diversity
operators for PermutationGenotype
s.
Given are n
elements e in E
two permutations p1, p2
of these elements. The function p(e)
returns the position of the
element e
in the permutation p
. This operator calculates the
following value:
diversity(p1,p2)=sum[e in E] |p1(e)-p2(e)|/(n^2/2)This value is bounded by
0
and 1
since
min { sum[e in E] |p1(e)-p2(e)| } = 0and
max { sum[e in E] |p1(e)-p2(e)| } = = 2 * sum[i=1 to n/2] (n-i)-(i-1) = = 2 * sum[i=1 to n/2] (n-2i+1) = = 2 * ( n^2/2 + n/2 - n/2(n/2+1)) = = 2 * ( n^2/2 + n/2 - n^2/4 - n/2) = = n^2/2.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
diversity
(PermutationGenotype<?> a, PermutationGenotype<?> b) Returns the genetic diversity of twoGenotype
s.
-
Constructor Details
-
DiversityPermutation
public DiversityPermutation()
-
-
Method Details
-
diversity
Description copied from interface:Diversity
Returns the genetic diversity of twoGenotype
s.- Specified by:
diversity
in interfaceDiversity<PermutationGenotype<?>>
- Parameters:
a
- the first genotypeb
- the second genotype- Returns:
- the diversity of two genotypes
-