* @param codec The codec, the type of network to use.
* @return The population.
*/
public static Population initPopulation(GenerateRandom rnd, RBFNetworkGenomeCODEC codec) {
// Create a RBF network to get the length.
final RBFNetwork network = new RBFNetwork(codec.getInputCount(), codec.getRbfCount(), codec.getOutputCount());
int size = network.getLongTermMemory().length;
// Create a new population, use a single species.
Population result = new BasicPopulation(POPULATION_SIZE, new DoubleArrayGenomeFactory(size));
BasicSpecies defaultSpecies = new BasicSpecies();
defaultSpecies.setPopulation(result);
result.getSpecies().add(defaultSpecies);
// Create a new population of random networks.
for (int i = 0; i < POPULATION_SIZE; i++) {
final DoubleArrayGenome genome = new DoubleArrayGenome(size);
network.reset(rnd);
System.arraycopy(network.getLongTermMemory(), 0, genome.getData(), 0, size);
defaultSpecies.add(genome);
}
// Set the genome factory to use the double array genome.
result.setGenomeFactory(new DoubleArrayGenomeFactory(size));