/// <summary> /// Create and return a NeatEvolutionAlgorithm object ready for running the NEAT algorithm/search. Various sub-parts /// of the algorithm are also constructed and connected up. /// This overload accepts a pre-built genome population and their associated/parent genome factory. /// </summary> public NeatEvolutionAlgorithm <NeatGenome> CreateEvolutionAlgorithm(IGenomeFactory <NeatGenome> genomeFactory, List <NeatGenome> genomeList) { // Create distance metric. Mismatched genes have a fixed distance of 10; for matched genes the distance is their weigth difference. IDistanceMetric distanceMetric = new ManhattanDistanceMetric(1.0, 0.0, 10.0); ISpeciationStrategy <NeatGenome> speciationStrategy = new ParallelKMeansClusteringStrategy <NeatGenome>(distanceMetric, _parallelOptions); // Create complexity regulation strategy. IComplexityRegulationStrategy complexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy(_complexityRegulationStr, _complexityThreshold); // Create the evolution algorithm. NeatEvolutionAlgorithm <NeatGenome> ea = new NeatEvolutionAlgorithm <NeatGenome>(_eaParams, speciationStrategy, complexityRegulationStrategy); // Create IBlackBox evaluator. _evaluator = CreateEvaluator(); // Create genome decoder. IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder = CreateGenomeDecoder(); // Create a genome list evaluator. This packages up the genome decoder with the genome evaluator. IGenomeListEvaluator <NeatGenome> innerEvaluator = new SerialGenomeListEvaluator <NeatGenome, IBlackBox>(genomeDecoder, _evaluator); /*new ParallelGenomeListEvaluator<NeatGenome, IBlackBox>(genomeDecoder, _evaluator, _parallelOptions);*/ // Wrap the list evaluator in a 'selective' evaulator that will only evaluate new genomes. That is, we skip re-evaluating any genomes // that were in the population in previous generations (elite genomes). This is determined by examining each genome's evaluation info object. IGenomeListEvaluator <NeatGenome> selectiveEvaluator = new SelectiveGenomeListEvaluator <NeatGenome>( innerEvaluator, SelectiveGenomeListEvaluator <NeatGenome> .CreatePredicate_OnceOnly()); // Initialize the evolution algorithm. ea.Initialize(selectiveEvaluator, genomeFactory, genomeList); // Finished. Return the evolution algorithm return(ea); }
/// <summary> /// Create and return a NeatEvolutionAlgorithm object ready for running the NEAT algorithm/search. Various sub-parts /// of the algorithm are also constructed and connected up. /// This overload accepts a pre-built genome population and their associated/parent genome factory. /// </summary> public NeatEvolutionAlgorithm <NeatGenome> CreateEvolutionAlgorithm(IGenomeFactory <NeatGenome> genomeFactory, List <NeatGenome> genomeList) { // Create distance metric. Mismatched genes have a fixed distance of 10; for matched genes the distance is their weigth difference. IDistanceMetric distanceMetric = new ManhattanDistanceMetric(1.0, 0.0, 10.0); ISpeciationStrategy <NeatGenome> speciationStrategy = new ParallelKMeansClusteringStrategy <NeatGenome>(distanceMetric, _parallelOptions); // Create complexity regulation strategy. IComplexityRegulationStrategy complexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy(_complexityRegulationStr, _complexityThreshold); // Create the evolution algorithm. NeatEvolutionAlgorithm <NeatGenome> ea = new NeatEvolutionAlgorithm <NeatGenome>(_eaParams, speciationStrategy, complexityRegulationStrategy); // Create IBlackBox evaluator. KeepawayEvaluator evaluator = new KeepawayEvaluator(); // Create genome decoder. IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder = CreateGenomeDecoder(); // TODO: evaulation scheme that re-evaulates existing genomes and takes average over time. // Create a genome list evaluator. This packages up the genome decoder with the genome evaluator. // IGenomeListEvaluator<NeatGenome> genomeListEvaluator = new ParallelGenomeListEvaluator<NeatGenome, IBlackBox>(genomeDecoder, evaluator, _parallelOptions); //IGenomeListEvaluator<NeatGenome> genomeListEvaluator = new ParallelGenomeListEvaluator<NeatGenome, IBlackBox>(genomeDecoder, evaluator); IGenomeListEvaluator <NeatGenome> genomeListEvaluator = new SerialGenomeListEvaluator <NeatGenome, IBlackBox>(genomeDecoder, evaluator, true); // Initialize the evolution algorithm. ea.Initialize(genomeListEvaluator, genomeFactory, genomeList); // Finished. Return the evolution algorithm return(ea); }
public override NeatEvolutionAlgorithm<NeatGenome> CreateEvolutionAlgorithm(IGenomeFactory<NeatGenome> genomeFactory, List<NeatGenome> genomeList) { var ea = DefaultNeatEvolutionAlgorithm; var evaluator = new LocalXorEvaluator(); // Create genome decoder. IGenomeDecoder<NeatGenome, IBlackBox> genomeDecoder = CreateGenomeDecoder(); // Create a genome list evaluator. This packages up the genome decoder with the genome evaluator. IGenomeListEvaluator<NeatGenome> innerEvaluator = new SerialGenomeListEvaluator<NeatGenome, IBlackBox>(genomeDecoder, evaluator); // Wrap the list evaluator in a 'selective' evaulator that will only evaluate new genomes. That is, we skip re-evaluating any genomes // that were in the population in previous generations (elite genomes). This is determined by examining each genome's evaluation info object. IGenomeListEvaluator<NeatGenome> selectiveEvaluator = new SelectiveGenomeListEvaluator<NeatGenome>( innerEvaluator, SelectiveGenomeListEvaluator<NeatGenome>.CreatePredicate_OnceOnly()); // Initialize the evolution algorithm. ea.Initialize(selectiveEvaluator, genomeFactory, genomeList); // Finished. Return the evolution algorithm return ea; }
public override NeatEvolutionAlgorithm <NeatGenome> CreateEvolutionAlgorithm(IGenomeFactory <NeatGenome> genomeFactory, List <NeatGenome> genomeList) { var ea = DefaultNeatEvolutionAlgorithm; var evaluator = new LocalXorEvaluator(); // Create genome decoder. IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder = CreateGenomeDecoder(); // Create a genome list evaluator. This packages up the genome decoder with the genome evaluator. IGenomeListEvaluator <NeatGenome> innerEvaluator = new SerialGenomeListEvaluator <NeatGenome, IBlackBox>(genomeDecoder, evaluator); // Wrap the list evaluator in a 'selective' evaulator that will only evaluate new genomes. That is, we skip re-evaluating any genomes // that were in the population in previous generations (elite genomes). This is determined by examining each genome's evaluation info object. IGenomeListEvaluator <NeatGenome> selectiveEvaluator = new SelectiveGenomeListEvaluator <NeatGenome>( innerEvaluator, SelectiveGenomeListEvaluator <NeatGenome> .CreatePredicate_OnceOnly()); // Initialize the evolution algorithm. ea.Initialize(selectiveEvaluator, genomeFactory, genomeList); // Finished. Return the evolution algorithm return(ea); }
/// <summary> /// Create and return a NeatEvolutionAlgorithm object ready for running the NEAT algorithm/search. Various sub-parts /// of the algorithm are also constructed and connected up. /// This overload accepts a pre-built genome population and their associated/parent genome factory. /// </summary> public NeatEvolutionAlgorithm <NeatGenome> CreateEvolutionAlgorithm(IGenomeFactory <NeatGenome> genomeFactory, List <NeatGenome> genomeList) { Debug.Log("........CreateEvolutionAlgorithm: Setting parameters"); // Create distance metric. Mismatched genes have a fixed distance of 10; for matched genes the distance is their weigth difference. IDistanceMetric distanceMetric = new ManhattanDistanceMetric(1.0, 0.0, 10.0); ISpeciationStrategy <NeatGenome> speciationStrategy = new KMeansClusteringStrategy <NeatGenome>(distanceMetric); // Create complexity regulation strategy. IComplexityRegulationStrategy complexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy(_complexityRegulationStr, _complexityThreshold); Debug.Log("........CreateEvolutionAlgorithm: Creating ea"); // Create the evolution algorithm. NeatEvolutionAlgorithm <NeatGenome> ea = new NeatEvolutionAlgorithm <NeatGenome>(_eaParams, speciationStrategy, complexityRegulationStrategy); Debug.Log("........CreateEvolutionAlgorithm: Creating evaluator"); // Create IBlackBox evaluator. CPPNRepairEvaluator2 evaluator = new CPPNRepairEvaluator2(this); evaluator.SetOriginalFeatures(_originalFeatures); Debug.Log("........CreateEvolutionAlgorithm: Creating genome decoder and serial evaluator"); // Create genome decoder. IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder = CreateGenomeDecoder(); // Create a genome list evaluator. This packages up the genome decoder with the genome evaluator. IGenomeListEvaluator <NeatGenome> innerEvaluator = new SerialGenomeListEvaluator <NeatGenome, IBlackBox>(genomeDecoder, evaluator); // Wrap the list evaluator in a 'selective' evaulator that will only evaluate new genomes. That is, we skip re-evaluating any genomes // that were in the population in previous generations (elite genomes). This is determiend by examining each genome's evaluation info object. /*IGenomeListEvaluator<NeatGenome> selectiveEvaluator = new SelectiveGenomeListEvaluator<NeatGenome>( * innerEvaluator, * SelectiveGenomeListEvaluator<NeatGenome>.CreatePredicate_OnceOnly()); */ // Initialize the evolution algorithm. Debug.Log("........CreateEvolutionAlgorithm: Initializing ea"); ea.Initialize(innerEvaluator, genomeFactory, genomeList); Debug.Log("........CreateEvolutionAlgorithm: Returning"); // Finished. Return the evolution algorithm return(ea); }
public NeatEvolutionAlgorithm <NeatGenome> CreateEvolutionAlgorithm(IGenomeFactory <NeatGenome> genomeFactory, List <NeatGenome> genomeList) { IDistanceMetric distanceMetric = new ManhattanDistanceMetric(1.0, 0.0, 10.0); ISpeciationStrategy <NeatGenome> speciationStrategy = new KMeansClusteringStrategy <NeatGenome>(distanceMetric); IComplexityRegulationStrategy complexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy(_complexityRegulationStr, _complexityThreshold); NeatEvolutionAlgorithm <NeatGenome> ea = new NeatEvolutionAlgorithm <NeatGenome>(_eaParams, speciationStrategy, complexityRegulationStrategy); // Create black box evaluator SimpleEvaluator evaluator = new SimpleEvaluator(); IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder = CreateGenomeDecoder(); IGenomeListEvaluator <NeatGenome> innerEvaluator = new SerialGenomeListEvaluator <NeatGenome, IBlackBox>(genomeDecoder, evaluator); IGenomeListEvaluator <NeatGenome> selectiveEvaluator = new SelectiveGenomeListEvaluator <NeatGenome>(innerEvaluator, SelectiveGenomeListEvaluator <NeatGenome> .CreatePredicate_OnceOnly()); ea.Initialize(selectiveEvaluator, genomeFactory, genomeList); return(ea); }
public NeatEvolutionAlgorithm<NeatGenome> CreateEvolutionAlgorithm(IGenomeFactory<NeatGenome> genomeFactory, List<NeatGenome> genomeList) { // Create distance metric. Mismatched genes have a fixed distance of 10; for matched genes the distance is their weigth difference. IDistanceMetric distanceMetric = new ManhattanDistanceMetric(1.0, 0.0, 10.0); ISpeciationStrategy<NeatGenome> speciationStrategy = new KMeansClusteringStrategy<NeatGenome>(distanceMetric); // Create complexity regulation strategy. IComplexityRegulationStrategy complexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy("absolute", 10); // Create the evolution algorithm. var ea = new NeatEvolutionAlgorithm<NeatGenome>( NeatEvolutionAlgorithmParameters, speciationStrategy, complexityRegulationStrategy); // Create IBlackBox evaluator. var evaluator = new RemoteXorEvaluator(); // Create genome decoder. IGenomeDecoder<NeatGenome, IBlackBox> genomeDecoder = CreateGenomeDecoder(); // Create a genome list evaluator. This packages up the genome decoder with the genome evaluator. IGenomeListEvaluator<NeatGenome> innerEvaluator = new SerialGenomeListEvaluator<NeatGenome, IBlackBox>(genomeDecoder, evaluator); // Wrap the list evaluator in a 'selective' evaulator that will only evaluate new genomes. That is, we skip re-evaluating any genomes // that were in the population in previous generations (elite genomes). This is determined by examining each genome's evaluation info object. IGenomeListEvaluator<NeatGenome> selectiveEvaluator = new SelectiveGenomeListEvaluator<NeatGenome>( innerEvaluator, SelectiveGenomeListEvaluator<NeatGenome>.CreatePredicate_OnceOnly()); // Initialize the evolution algorithm. ea.Initialize(selectiveEvaluator, genomeFactory, genomeList); // Finished. Return the evolution algorithm return ea; }
/// <summary> /// Create and return a NeatEvolutionAlgorithm object ready for running the NEAT algorithm/search. Various sub-parts /// of the algorithm are also constructed and connected up. /// This overload accepts a pre-built genome population and their associated/parent genome factory. /// </summary> public NeatEvolutionAlgorithm<NeatGenome> CreateEvolutionAlgorithm(IGenomeFactory<NeatGenome> genomeFactory, List<NeatGenome> genomeList) { // Create distance metric. Mismatched genes have a fixed distance of 10; for matched genes the distance is their weigth difference. IDistanceMetric distanceMetric = new ManhattanDistanceMetric(1.0, 0.0, 10.0); ISpeciationStrategy<NeatGenome> speciationStrategy = new ParallelKMeansClusteringStrategy<NeatGenome>(distanceMetric, _parallelOptions); // Create complexity regulation strategy. IComplexityRegulationStrategy complexityRegulationStrategy = ExperimentUtils.CreateComplexityRegulationStrategy(_complexityRegulationStr, _complexityThreshold); // Create the evolution algorithm. NeatEvolutionAlgorithm<NeatGenome> ea = new NeatEvolutionAlgorithm<NeatGenome>(_eaParams, speciationStrategy, complexityRegulationStrategy); // Create IBlackBox evaluator. DeepBeliefNetworkBiasEvaluator evaluator = new DeepBeliefNetworkBiasEvaluator(); // Create genome decoder. Decodes to a neural network packaged with an activation scheme that defines a fixed number of activations per evaluation. IGenomeDecoder<NeatGenome, IBlackBox> genomeDecoder = CreateGenomeDecoder(_lengthCppnInput); // Create a genome list evaluator. This packages up the genome decoder with the genome evaluator. IGenomeListEvaluator<NeatGenome> innerEvaluator = null; if (Constants.IS_MULTI_THREADING) { innerEvaluator = new ParallelGenomeListEvaluator<NeatGenome, IBlackBox>(genomeDecoder, evaluator, _parallelOptions); } else { innerEvaluator = new SerialGenomeListEvaluator<NeatGenome, IBlackBox>(genomeDecoder, evaluator); } // Wrap the list evaluator in a 'selective' evaulator that will only evaluate new genomes. That is, we skip re-evaluating any genomes // that were in the population in previous generations (elite genomes). This is determiend by examining each genome's evaluation info object. IGenomeListEvaluator<NeatGenome> selectiveEvaluator = new SelectiveGenomeListEvaluator<NeatGenome>( innerEvaluator, SelectiveGenomeListEvaluator<NeatGenome>.CreatePredicate_OnceOnly()); // Initialize the evolution algorithm. ea.Initialize(selectiveEvaluator, genomeFactory, genomeList); // Finished. Return the evolution algorithm return ea; }