Example usage for org.apache.commons.math3.genetics RandomKey inducedPermutation

List of usage examples for org.apache.commons.math3.genetics RandomKey inducedPermutation

Introduction

In this page you can find the example usage for org.apache.commons.math3.genetics RandomKey inducedPermutation.

Prototype

public static <S> List<Double> inducedPermutation(final List<S> originalData, final List<S> permutedData)
        throws DimensionMismatchException, MathIllegalArgumentException 

Source Link

Document

Generates a representation of a permutation corresponding to a permutation which yields permutedData when applied to originalData.

Usage

From source file:tmp.GACombGraphMoore.java

/**
 * Initializes a random population/*from w  w  w  . ja v a 2 s .  c  om*/
 */
private static ElitisticListPopulation randomPopulation(String... args) {
    List<Chromosome> popList = new ArrayList<Chromosome>();
    int i = 0;
    if (args != null && args.length > 0) {
        if (args.length == DIMENSION || ((args = args[0].split(",")) != null && args.length == DIMENSION)) {
            List<Integer> start = new ArrayList<>();
            for (String str : args) {
                start.add(Integer.parseInt(str.replaceAll("\\D", "").trim()));
            }
            System.out.println("Induced vector");
            System.out.println(start);
            Chromosome randChrom = new MinPermutations(RandomKey.inducedPermutation(sequence, start));
            System.out.println(randChrom);
            popList.add(randChrom);
            i++;
        }
    }
    for (; i < POPULATION_SIZE; i++) {
        Chromosome randChrom = new MinPermutations(RandomKey.randomPermutation(DIMENSION));
        popList.add(randChrom);
    }
    return new ElitisticListPopulation(popList, popList.size(), ELITISM_RATE);
}

From source file:tmp.GACombPermutation.java

/**
 * Initializes a random population//from   w  w w  .  jav  a  2 s  . co m
 */
private static ElitisticListPopulation randomPopulation(String... args) {
    List<Chromosome> popList = new ArrayList<Chromosome>();
    int i = 0;
    if (args != null && args.length > 0) {
        if (args.length == DIMENSION || ((args = args[0].split(",")) != null && args.length == DIMENSION)) {
            List<Integer> start = new ArrayList<>();
            for (String str : args) {
                start.add(Integer.parseInt(str.trim().replaceAll("\\D", "")));
            }
            Chromosome randChrom = new MinPermutations(RandomKey.inducedPermutation(sequence, start));
            popList.add(randChrom);
            i++;
        }
    }
    for (; i < POPULATION_SIZE; i++) {
        Chromosome randChrom = new MinPermutations(RandomKey.randomPermutation(DIMENSION));
        popList.add(randChrom);
    }
    return new ElitisticListPopulation(popList, popList.size(), ELITISM_RATE);
}