/** * Create a NEAT population. * * @param architecture The architecture string to use. * @param input The input count. * @param output The output count. * @return The population. */ public MLMethod create(final String architecture, final int input, final int output) { if (input <= 0) { throw new EncogError("Must have at least one input for NEAT."); } if (output <= 0) { throw new EncogError("Must have at least one output for NEAT."); } final Map<String, String> args = ArchitectureParse.parseParams(architecture); final ParamsHolder holder = new ParamsHolder(args); final int populationSize = holder.getInt(MLMethodFactory.PROPERTY_POPULATION_SIZE, false, 1000); final int cycles = holder.getInt(MLMethodFactory.PROPERTY_CYCLES, false, NEATPopulation.DEFAULT_CYCLES); ActivationFunction af = this.factory.create( holder.getString(MLMethodFactory.PROPERTY_AF, false, MLActivationFactory.AF_SSIGMOID)); NEATPopulation pop = new NEATPopulation(input, output, populationSize); pop.reset(); pop.setActivationCycles(cycles); pop.setNEATActivationFunction(af); return pop; }
/** {@inheritDoc} */ @Override public void mutateWeight( final Random rnd, final NEATLinkGene linkGene, final double weightRange) { final double delta = rnd.nextGaussian() * this.sigma; double w = linkGene.getWeight() + delta; w = NEATPopulation.clampWeight(w, weightRange); linkGene.setWeight(w); }
@Override public MLMethod decode(final Genome genome) { final NEATPopulation pop = (NEATPopulation) genome.getPopulation(); final Substrate substrate = pop.getSubstrate(); return decode(pop, substrate, genome); }