|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.commons.math.genetics.Chromosome
org.apache.commons.math.genetics.AbstractListChromosome<Double>
org.apache.commons.math.genetics.RandomKey<T>
T - type of the permuted objectspublic abstract class RandomKey<T>
Random Key chromosome is used for permutation representation. It is a vector of a fixed length of real numbers in [0,1] interval. The index of the i-th smallest value in the vector represents an i-th member of the permutation.
For example, the random key [0.2, 0.3, 0.8, 0.1] corresponds to the permutation of indices (3,0,1,2). If the original (unpermuted) sequence would be (a,b,c,d), this would mean the sequence (d,a,b,c).
With this representation, common operators like n-point crossover can be used, because any such chromosome represents a valid permutation.
Since the chromosome (and thus its arrayRepresentation) is immutable, the array representation is sorted only once in the constructor.
For details, see:
| Constructor Summary | |
|---|---|
RandomKey(Double[] representation)
Constructor. |
|
RandomKey(List<Double> representation)
Constructor. |
|
| Method Summary | ||
|---|---|---|
static
|
comparatorPermutation(List<S> data,
Comparator<S> comparator)
Generates a representation of a permutation corresponding to the data sorted by comparator. |
|
List<T> |
decode(List<T> sequence)
Permutes the sequence of objects of type T according to the
permutation this chromosome represents. |
|
static List<Double> |
identityPermutation(int l)
Generates a representation corresponding to an identity permutation of length l which can be passed to the RandomKey constructor. |
|
static
|
inducedPermutation(List<S> originalData,
List<S> permutedData)
Generates a representation of a permutation corresponding to a permutation which yields permutedData when applied to
originalData. |
|
static List<Double> |
randomPermutation(int l)
Generates a representation corresponding to a random permutation of length l which can be passed to the RandomKey constructor. |
|
String |
toString()
|
|
| Methods inherited from class org.apache.commons.math.genetics.AbstractListChromosome |
|---|
getLength, newFixedLengthChromosome |
| Methods inherited from class org.apache.commons.math.genetics.Chromosome |
|---|
compareTo, getFitness, searchForFitnessUpdate |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.commons.math.genetics.Fitness |
|---|
fitness |
| Constructor Detail |
|---|
public RandomKey(List<Double> representation)
representation - list of [0,1] values representing the permutationpublic RandomKey(Double[] representation)
representation - array of [0,1] values representing the permutation| Method Detail |
|---|
public List<T> decode(List<T> sequence)
sequence of objects of type T according to the
permutation this chromosome represents. For example, if this chromosome
represents a permutation (3,0,1,2), and the unpermuted sequence is
(a,b,c,d), this yields (d,a,b,c).
decode in interface PermutationChromosome<T>sequence - the unpermuted (original) sequence of objects
sequence represented by this
permutationpublic static final List<Double> randomPermutation(int l)
l - length of the permutation
public static final List<Double> identityPermutation(int l)
l - length of the permutation
public static <S> List<Double> comparatorPermutation(List<S> data,
Comparator<S> comparator)
data sorted by comparator. The
data is not modified during the process.
This is useful if you want to inject some permutations to the initial
population.
S - type of the datadata - list of data determining the ordercomparator - how the data will be compared
public static <S> List<Double> inducedPermutation(List<S> originalData,
List<S> permutedData)
throws IllegalArgumentException
permutedData when applied to
originalData.
This method can be viewed as an inverse to decode(List).
S - type of the dataoriginalData - the original, unpermuted datapermutedData - the data, somehow permuted
originalData -> permutedData
IllegalArgumentException - iff the permutedData and originalData contains different datapublic String toString()
toString in class AbstractListChromosome<Double>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||