List of usage examples for org.apache.commons.math3.genetics RandomKey randomPermutation
public static final List<Double> randomPermutation(final int l)
From source file:tmp.GACombGraphMoore.java
/** * Initializes a random population//ww w .j ava 2 s. c o 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.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 www .jav a 2 s . c o 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); }
From source file:tmp.GeneticAlgorithmTestPermutations.java
/** * Initializes a random population//from w w w .j av a 2 s .c o m */ private static ElitisticListPopulation randomPopulation() { List<Chromosome> popList = new ArrayList<Chromosome>(); for (int i = 0; i < POPULATION_SIZE; i++) { Chromosome randChrom = new MinPermutations(RandomKey.randomPermutation(DIMENSION)); popList.add(randChrom); } return new ElitisticListPopulation(popList, popList.size(), ELITISM_RATE); }