CheckStyle.

This commit is contained in:
Gilles Sadowski 2024-08-24 12:47:44 +02:00
parent 7b0e1a051d
commit 9d54ae1b5b
6 changed files with 16 additions and 16 deletions

View File

@ -67,7 +67,7 @@ public abstract class BinaryChromosome extends AbstractListChromosome<Integer> {
*/
public static List<Integer> randomBinaryRepresentation(int length) {
// random binary list
List<Integer> rList= new ArrayList<> (length);
List<Integer> rList= new ArrayList<>(length);
for (int j=0; j<length; j++) {
rList.add(GeneticAlgorithm.getRandomGenerator().nextInt(2));
}

View File

@ -72,7 +72,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
public RandomKey(final List<Double> representation) throws InvalidRepresentationException {
super(representation);
// store the sorted representation
List<Double> sortedRepr = new ArrayList<> (getRepresentation());
List<Double> sortedRepr = new ArrayList<>(getRepresentation());
Collections.sort(sortedRepr);
sortedRepresentation = Collections.unmodifiableList(sortedRepr);
// store the permutation of [0,1,...,n-1] list for toString() and isSame() methods
@ -126,10 +126,10 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
}
// do not modify the original representation
List<Double> reprCopy = new ArrayList<> (representation);
List<Double> reprCopy = new ArrayList<>(representation);
// now find the indices in the original repr and use them for permuting
List<S> res = new ArrayList<> (l);
List<S> res = new ArrayList<>(l);
for (int i=0; i<l; i++) {
int index = reprCopy.indexOf(sortedRepr.get(i));
res.add(sequence.get(index));
@ -264,7 +264,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
}
int l = originalData.size();
List<S> origDataCopy = new ArrayList<> (originalData);
List<S> origDataCopy = new ArrayList<>(originalData);
Double[] res = new Double[l];
for (int i=0; i<l; i++) {
@ -291,7 +291,7 @@ public abstract class RandomKey<T> extends AbstractListChromosome<Double> implem
* @return list of integers from 0 to l-1
*/
private static List<Integer> baseSequence(final int l) {
List<Integer> baseSequence = new ArrayList<> (l);
List<Integer> baseSequence = new ArrayList<>(l);
for (int i=0; i<l; i++) {
baseSequence.add(i);
}

View File

@ -46,7 +46,7 @@ public class RandomKeyMutation implements MutationPolicy {
List<Double> repr = originalRk.getRepresentation();
int rInd = GeneticAlgorithm.getRandomGenerator().nextInt(repr.size());
List<Double> newRepr = new ArrayList<> (repr);
List<Double> newRepr = new ArrayList<>(repr);
newRepr.set(rInd, GeneticAlgorithm.getRandomGenerator().nextDouble());
return originalRk.newFixedLengthChromosome(newRepr);

View File

@ -84,7 +84,7 @@ public class TournamentSelection implements SelectionPolicy {
};
// create a copy of the chromosome list
List<Chromosome> chromosomes = new ArrayList<> (population.getChromosomes());
List<Chromosome> chromosomes = new ArrayList<>(population.getChromosomes());
for (int i=0; i<this.arity; i++) {
// select a random individual and add it to the tournament
int rind = GeneticAlgorithm.getRandomGenerator().nextInt(chromosomes.size());

View File

@ -302,7 +302,7 @@ public class KMeansPlusPlusClusterer<T extends Clusterable> extends Clusterer<T>
// Convert to list for indexed access. Make it unmodifiable, since removal of items
// would screw up the logic of this method.
final List<T> pointList = Collections.unmodifiableList(new ArrayList<> (points));
final List<T> pointList = Collections.unmodifiableList(new ArrayList<>(points));
// The number of points in the list.
final int numPoints = pointList.size();
@ -386,7 +386,7 @@ public class KMeansPlusPlusClusterer<T extends Clusterable> extends Clusterer<T>
final T p = pointList.get(nextPointIndex);
resultSet.add(new CentroidCluster<T> (p));
resultSet.add(new CentroidCluster<>(p));
// Mark it as taken.
taken[nextPointIndex] = true;

View File

@ -49,7 +49,7 @@ public class ListPopulationTest {
}
};
ArrayList<Chromosome> chromosomes = new ArrayList<> ();
ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(c1);
chromosomes.add(c2);
chromosomes.add(c3);
@ -67,7 +67,7 @@ public class ListPopulationTest {
@Test
public void testChromosomes() {
final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
@ -115,7 +115,7 @@ public class ListPopulationTest {
@Test(expected = NotPositiveException.class)
public void testChromosomeListConstructorPopulationLimitNotPositive() {
final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
new ListPopulation(chromosomes, -10) {
@Override
@ -128,7 +128,7 @@ public class ListPopulationTest {
@Test(expected = NumberIsTooLargeException.class)
public void testConstructorListOfChromosomesBiggerThanPopulationSize() {
final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
@ -143,7 +143,7 @@ public class ListPopulationTest {
@Test(expected=NumberIsTooLargeException.class)
public void testAddTooManyChromosomes() {
final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
@ -201,7 +201,7 @@ public class ListPopulationTest {
@Test(expected=NumberIsTooSmallException.class)
public void testSetPopulationLimitTooSmall() {
final ArrayList<Chromosome> chromosomes = new ArrayList<> ();
final ArrayList<Chromosome> chromosomes = new ArrayList<>();
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));
chromosomes.add(new DummyBinaryChromosome(BinaryChromosome.randomBinaryRepresentation(3)));