parent
f58f6e867b
commit
fbb1c80d09
@ -305,8 +305,8 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
|
||||
/**
|
||||
* This method calculates the distance between two double values
|
||||
*
|
||||
* @param d1
|
||||
* @param d2
|
||||
* @param indy
|
||||
* @param p
|
||||
* @return The scalar distances between d1 and d2
|
||||
*/
|
||||
private double distance(AbstractEAIndividual indy, double[] p) {
|
||||
@ -357,19 +357,8 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
|
||||
return metric.distance(species1.getBestEAIndividual(), species2.getBestEAIndividual()) < mergeDist;
|
||||
}
|
||||
|
||||
// /** This method decides if a unclustered individual belongs to an already established species.
|
||||
// * @param indy A unclustered individual.
|
||||
// * @param species A species.
|
||||
// * @return True or False.
|
||||
// */
|
||||
// public boolean belongsToSpecies(AbstractEAIndividual indy, Population species, Population pop) {
|
||||
// // @todo perhaps the same as in convergingSpecies
|
||||
// return false;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int[] associateLoners(Population loners, Population[] species, Population referencePop) {
|
||||
// tmpIndy = (AbstractEAIndividual)loners.getEAIndividual(0).clone();
|
||||
int[] res = new int[loners.size()];
|
||||
System.err.println("Warning, associateLoners not implemented for " + this.getClass());
|
||||
Arrays.fill(res, -1);
|
||||
@ -413,7 +402,7 @@ public class ClusteringKMeans implements InterfaceClustering, java.io.Serializab
|
||||
|
||||
/**
|
||||
* This method allows you to set/get the number of
|
||||
* clusters tofind
|
||||
* clusters to find
|
||||
*
|
||||
* @return The current number of clusters to find.
|
||||
*/
|
||||
|
@ -375,7 +375,7 @@ public class Population extends ArrayList<AbstractEAIndividual> implements Popul
|
||||
this.historyList = new LinkedList<>();
|
||||
this.generationCount = 0;
|
||||
this.functionCallCount = 0;
|
||||
double[] popSeed = null;
|
||||
double[] popSeed;
|
||||
if (this.populationArchive != null) {
|
||||
this.populationArchive.clear();
|
||||
this.populationArchive.initialize();
|
||||
|
@ -31,7 +31,7 @@ public final class ToolBox {
|
||||
ret[i] = fields[i].toString();
|
||||
}
|
||||
|
||||
System.arraycopy(additionalValues, enumLen - enumLen, ret, enumLen, ret.length - enumLen);
|
||||
System.arraycopy(additionalValues, 0, ret, enumLen, ret.length - enumLen);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -25,12 +25,36 @@ public class PopulationTest {
|
||||
|
||||
@Test
|
||||
public void testGetData() throws Exception {
|
||||
// Simple data
|
||||
emptyPopulation.putData("someInt", 12);
|
||||
assertEquals(12, emptyPopulation.getData("someInt"));
|
||||
|
||||
// Arrays
|
||||
double[] doubleArray = new double[]{1.0};
|
||||
emptyPopulation.putData("someDoubleArray", doubleArray);
|
||||
assertArrayEquals(doubleArray, (double[])emptyPopulation.getData("someDoubleArray"), 0.0);
|
||||
|
||||
// Objects
|
||||
Object obj = new Object();
|
||||
emptyPopulation.putData("someObject", obj);
|
||||
assertEquals(obj, emptyPopulation.getData("someObject"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasData() throws Exception {
|
||||
assertFalse(emptyPopulation.hasData("someKey"));
|
||||
|
||||
// Simple data
|
||||
emptyPopulation.putData("someInt", 12);
|
||||
assertTrue(emptyPopulation.hasData("someInt"));
|
||||
|
||||
// Arrays
|
||||
emptyPopulation.putData("someDoubleArray", new double[]{1.0});
|
||||
assertTrue(emptyPopulation.hasData("someDoubleArray"));
|
||||
|
||||
// Objects
|
||||
emptyPopulation.putData("someObject", new Object());
|
||||
assertTrue(emptyPopulation.hasData("someObject"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -70,22 +94,33 @@ public class PopulationTest {
|
||||
|
||||
@Test
|
||||
public void testSetUseHistory() throws Exception {
|
||||
emptyPopulation.setUseHistory(true);
|
||||
assertTrue(emptyPopulation.isUsingHistory());
|
||||
|
||||
emptyPopulation.setUseHistory(false);
|
||||
assertFalse(emptyPopulation.isUsingHistory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUsingHistory() throws Exception {
|
||||
|
||||
// Not using history by default
|
||||
assertFalse(emptyPopulation.isUsingHistory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetAutoAging() throws Exception {
|
||||
emptyPopulation.setAutoAging(true);
|
||||
assertTrue(emptyPopulation.isAutoAging());
|
||||
|
||||
|
||||
emptyPopulation.setAutoAging(false);
|
||||
assertFalse(emptyPopulation.isAutoAging());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAutoAging() throws Exception {
|
||||
|
||||
// Is auto-aging by default
|
||||
assertTrue(emptyPopulation.isAutoAging());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user