/// <summary> /// Construct a neat trainer with a new population. The new population is /// created from the specified parameters. /// </summary> /// <param name="calculateScore">The score calculation object.</param> /// <param name="inputCount">The input neuron count.</param> /// <param name="outputCount">The output neuron count.</param> /// <param name="populationSize">The population size.</param> public NEATTraining(ICalculateScore calculateScore, int inputCount, int outputCount, int populationSize) { this.inputCount = inputCount; this.outputCount = outputCount; CalculateScore = new GeneticScoreAdapter(calculateScore); Comparator = new GenomeComparator(CalculateScore); Population = new NEATPopulation(inputCount, outputCount, populationSize); Init(); }
/// <summary> /// Construct neat training with an existing population. /// </summary> /// <param name="calculateScore">The score object to use.</param> /// <param name="population">The population to use.</param> public NEATTraining(ICalculateScore calculateScore, IPopulation population) { if (population.Size() < 1) { throw new TrainingError("Population can not be empty."); } var genome = (NEATGenome) population.Genomes[0]; CalculateScore = new GeneticScoreAdapter(calculateScore); Comparator = new GenomeComparator(CalculateScore); Population = (population); inputCount = genome.InputCount; outputCount = genome.OutputCount; Init(); }
/// <summary> /// Construct a neat trainer with a new population. /// </summary> /// <param name="calculateScore">The score calculation object.</param> /// <param name="inputCount">The input neuron count.</param> /// <param name="outputCount">The output neuron count.</param> /// <param name="populationSize">The population size.</param> public NEATTraining(ICalculateScore calculateScore, int inputCount, int outputCount, int populationSize) { this.inputCount = inputCount; this.outputCount = outputCount; CalculateScore = new GeneticScoreAdapter(calculateScore); Comparator = new GenomeComparator(CalculateScore); Population = new BasicPopulation(populationSize); // create the initial population for (int i = 0; i < populationSize; i++) { Population.Add( new NEATGenome(this, Population.AssignGenomeID(), inputCount, outputCount)); } Init(); }