public EvolutionAlgorithmController(IEvolutionAlgorithm ea) { _ea = ea; _currentGeneration = 0; _runState = RunState.Ready; _updateScheme = new UpdateScheme(new TimeSpan(0, 0, 1)); }
/// <summary> /// Construct with the provided IGenomeDecoder and ICoevolutionPhenomeEvaluator. /// The number of parallel threads defaults to Environment.ProcessorCount. /// </summary> public HostParasiteCoevolutionListEvaluator(int parasiteGenomesPerEvaluation, int hallOfFameGenomesPerEvaluation, IEvolutionAlgorithm <TGenome> eaParasite, IGenomeDecoder <TGenome, TPhenome> genomeDecoder, ICoevolutionPhenomeListEvaluator <TPhenome> phenomeListEvaluator) : this(parasiteGenomesPerEvaluation, hallOfFameGenomesPerEvaluation, eaParasite, genomeDecoder, phenomeListEvaluator, new ParallelOptions()) { }
/// <summary> /// Constructs a new instance. /// </summary> /// <param name="ea">The <see cref="IEvolutionAlgorithm"/> to wrap.</param> /// <param name="updateScheme">Evolution algorithm update event scheme.</param> public EvolutionAlgorithmRunner( IEvolutionAlgorithm ea, UpdateScheme updateScheme) { _ea = ea ?? throw new ArgumentNullException(nameof(ea)); // Init update scheme. _updateScheme = updateScheme ?? throw new ArgumentNullException(nameof(updateScheme)); _isUpdateDueFn = CreateIsUpdateDueFunction(_updateScheme); }
/// <summary> /// Constructs a new instance. /// </summary> /// <param name="ea">The <see cref="IEvolutionAlgorithm"/> to wrap.</param> public EvolutionAlgorithmRunner(IEvolutionAlgorithm ea) { _ea = ea ?? throw new ArgumentNullException(nameof(ea)); // Set to ready state. _runState = RunState.Ready; // Set a default update scheme of once per second. _updateScheme = UpdateScheme.CreateTimeSpanUpdateScheme(TimeSpan.FromSeconds(1)); }
/// <summary> /// Called when a new evolution algorithm is initialized. Clean up any existing event listeners and /// connect up to the new evolution algorithm. /// </summary> public void Reconnect(IEvolutionAlgorithm<NeatGenome> ea) { // Clean up. if(null != _ea) { _ea.UpdateEvent -= new EventHandler(_ea_UpdateEvent); } // Reconnect. _ea = ea; _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent); }
/// <summary> /// Construct the form with the provided details and data sources. /// </summary> public SummaryGraphForm(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, SummaryDataSource[] dataSourceArray, IEvolutionAlgorithm<NeatGenome> ea) { InitializeComponent(); this.Text = string.Format("SharpNEAT Graph - {0}", title); _dataSourceArray = dataSourceArray; InitGraph(title, xAxisTitle, y1AxisTitle, y2AxisTitle, dataSourceArray); _ea = ea; if(null != ea) { _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent); } }
/// <summary> /// Construct with the provided form title, genome view/renderer and evolution algorithm. We listen to update events /// from the evolution algorithm and cleanly detach from it when this form closes. /// </summary> public GenomeForm(string title, AbstractGenomeView genomeViewControl, IEvolutionAlgorithm<NeatGenome> ea) { InitializeComponent(); this.Text = title; _genomeViewControl = genomeViewControl; genomeViewControl.Dock = DockStyle.Fill; this.Controls.Add(genomeViewControl); _ea = ea; if(null != ea) { _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent); } }
/// <summary> /// Called when a new evolution algorithm is initialized. Clean up any existing event listeners and /// connect up to the new evolution algorithm. /// </summary> public void Reconnect(IEvolutionAlgorithm<NeatGenome> ea) { // Clean up. if(null != _ea) { _ea.UpdateEvent -= new EventHandler(_ea_UpdateEvent); } foreach(PointPairList ppl in _pointPlotArray) { ppl.Clear(); } // Reconnect. _ea = ea; _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent); }
/// <summary> /// Construct with the provided IGenomeDecoder, ICoevolutionPhenomeEvaluator and ParalleOptions. /// The number of parallel threads defaults to Environment.ProcessorCount. /// </summary> public HostParasiteCoevolutionListEvaluator(int parasiteGenomesPerEvaluation, int hallOfFameGenomesPerEvaluation, IEvolutionAlgorithm <TGenome> eaParasite, IGenomeDecoder <TGenome, TPhenome> genomeDecoder, ICoevolutionPhenomeListEvaluator <TPhenome> phenomeListEvaluator, ParallelOptions options) { Debug.Assert(parasiteGenomesPerEvaluation >= 0); Debug.Assert(hallOfFameGenomesPerEvaluation >= 0); _parasiteGenomesPerEvaluation = parasiteGenomesPerEvaluation; _hallOfFameGenomesPerEvaluation = hallOfFameGenomesPerEvaluation; _genomeDecoder = genomeDecoder; _phenomeListEvaluator = phenomeListEvaluator; _parallelOptions = options; _hallOfFame = new List <TGenome>(); _parasiteGenomes = new List <TGenome>(); _random = new Random(); eaParasite.UpdateEvent += new EventHandler(eaParasite_UpdateEvent); }
private IEnumerator PauseRoutine(IEvolutionAlgorithm <NeatGenome> ea) { yield return(null); ea.StartContinue(); }