/// <summary> /// Create a new instance of <see cref="NeatEvolutionAlgorithm{T}"/> for the given neat experiment. /// </summary> /// <param name="neatExperiment">A neat experiment instance; this conveys everything required to create a new evolution algorithm instance that is ready to be run.</param> /// <returns>A new instance of <see cref="NeatEvolutionAlgorithm{T}"/>.</returns> public static NeatEvolutionAlgorithm <double> CreateNeatEvolutionAlgorithm( INeatExperiment <double> neatExperiment) { // Create a genomeList evaluator based on the experiment's configuration settings. var genomeListEvaluator = CreateGenomeListEvaluator(neatExperiment); // Create a MetaNeatGenome. var metaNeatGenome = CreateMetaNeatGenome(neatExperiment); // Create an initial population of genomes. NeatPopulation <double> neatPop = NeatPopulationFactory <double> .CreatePopulation( metaNeatGenome, connectionsProportion : neatExperiment.InitialInterconnectionsProportion, popSize : neatExperiment.PopulationSize); // Create a speciation strategy based on the experiment's configuration settings. var speciationStrategy = CreateSpeciationStrategy(neatExperiment); // Create an instance of the default connection weight mutation scheme. var weightMutationScheme = WeightMutationSchemeFactory.CreateDefaultScheme(neatExperiment.ConnectionWeightScale); // Pull all of the parts together into an evolution algorithm instance. var ea = new NeatEvolutionAlgorithm <double>( neatExperiment.NeatEvolutionAlgorithmSettings, genomeListEvaluator, speciationStrategy, neatPop, neatExperiment.ComplexityRegulationStrategy, neatExperiment.ReproductionAsexualSettings, neatExperiment.ReproductionSexualSettings, weightMutationScheme); return(ea); }
/// <summary> /// Create a new NeatPopulation with randomly initialised genomes. /// Genomes are randomly initialised by giving each a random subset of all possible connections between the input and output layer. /// </summary> /// <param name="metaNeatGenome">Genome metadata, e.g. the number of input and output nodes that each genome should have.</param> /// <param name="connectionsProportion">The proportion of possible connections between the input and output layers, to create in each new genome.</param> /// <param name="popSize">Population size. The number of new genomes to create.</param> /// <returns>A new instance of <see cref="NeatPopulation{T}"/>.</returns> public static NeatPopulation <T> CreatePopulation( MetaNeatGenome <T> metaNeatGenome, double connectionsProportion, int popSize) { var factory = new NeatPopulationFactory <T>(metaNeatGenome, connectionsProportion, RandomDefaults.CreateRandomSource()); return(factory.CreatePopulation(popSize)); }