Formatting, use List instead of ArrayList.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1550977 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f3a785108f
commit
721730b00b
|
@ -40,7 +40,7 @@ public abstract class AbstractListChromosome<T> extends Chromosome {
|
|||
*/
|
||||
public AbstractListChromosome(final List<T> representation) throws InvalidRepresentationException {
|
||||
checkValidity(representation);
|
||||
this.representation = Collections.unmodifiableList(new ArrayList<T> (representation));
|
||||
this.representation = Collections.unmodifiableList(new ArrayList<T>(representation));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -55,7 +55,6 @@ public class ElitisticListPopulation extends ListPopulation {
|
|||
|
||||
super(chromosomes, populationLimit);
|
||||
setElitismRate(elitismRate);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +70,6 @@ public class ElitisticListPopulation extends ListPopulation {
|
|||
|
||||
super(populationLimit);
|
||||
setElitismRate(elitismRate);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -139,13 +139,13 @@ public class NPointCrossover<T> implements CrossoverPolicy {
|
|||
final List<T> parent1Rep = first.getRepresentation();
|
||||
final List<T> parent2Rep = second.getRepresentation();
|
||||
// and of the children
|
||||
final ArrayList<T> child1Rep = new ArrayList<T>(first.getLength());
|
||||
final ArrayList<T> child2Rep = new ArrayList<T>(second.getLength());
|
||||
final List<T> child1Rep = new ArrayList<T>(first.getLength());
|
||||
final List<T> child2Rep = new ArrayList<T>(second.getLength());
|
||||
|
||||
final RandomGenerator random = GeneticAlgorithm.getRandomGenerator();
|
||||
|
||||
ArrayList<T> c1 = child1Rep;
|
||||
ArrayList<T> c2 = child2Rep;
|
||||
List<T> c1 = child1Rep;
|
||||
List<T> c2 = child2Rep;
|
||||
|
||||
int remainingPoints = crossoverPoints;
|
||||
int lastIndex = 0;
|
||||
|
@ -160,7 +160,7 @@ public class NPointCrossover<T> implements CrossoverPolicy {
|
|||
}
|
||||
|
||||
// swap the children for the next segment
|
||||
ArrayList<T> tmp = c1;
|
||||
List<T> tmp = c1;
|
||||
c1 = c2;
|
||||
c2 = tmp;
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ public class OnePointCrossover<T> implements CrossoverPolicy {
|
|||
final List<T> parent1Rep = first.getRepresentation();
|
||||
final List<T> parent2Rep = second.getRepresentation();
|
||||
// and of the children
|
||||
final ArrayList<T> child1Rep = new ArrayList<T> (first.getLength());
|
||||
final ArrayList<T> child2Rep = new ArrayList<T> (second.getLength());
|
||||
final List<T> child1Rep = new ArrayList<T>(first.getLength());
|
||||
final List<T> child2Rep = new ArrayList<T>(second.getLength());
|
||||
|
||||
// select a crossover point at random (0 and length makes no sense)
|
||||
final int crossoverIndex = 1 + (GeneticAlgorithm.getRandomGenerator().nextInt(length-2));
|
||||
|
|
|
@ -64,7 +64,7 @@ public class TournamentSelection implements SelectionPolicy {
|
|||
* Helper for {@link #select(Population)}. Draw {@link #arity} random chromosomes without replacement from the
|
||||
* population, and then select the fittest chromosome among them.
|
||||
*
|
||||
* @param population the population from which the chromosomes are choosen.
|
||||
* @param population the population from which the chromosomes are chosen.
|
||||
* @return the selected chromosome.
|
||||
* @throws MathIllegalArgumentException if the tournament arity is bigger than the population size
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue