/// <summary> /// Update the time series data. /// </summary> /// <param name="eaStats">Evolution algorithm statistics object.</param> /// <param name="popStats">Population statistics object.</param> public override void UpdateData( EvolutionAlgorithmStatistics eaStats, PopulationStatistics popStats) { _ppl.Add(eaStats.Generation, eaStats.EvaluationsPerSec); RefreshGraph(); }
/// <summary> /// Determine the complexity regulation mode that the evolution algorithm search should be in given the /// provided evolution algorithm statistics object, and set the current mode to that mode. /// </summary> /// <param name="eaStats">Evolution algorithm statistics.</param> /// <param name="popStats">Population statistics.</param> /// <returns>The determined <see cref="ComplexityRegulationMode"/>.</returns> public ComplexityRegulationMode UpdateMode( EvolutionAlgorithmStatistics eaStats, PopulationStatistics popStats) { // This is the null strategy, therefore do nothing. return(ComplexityRegulationMode.Complexifying); }
public void TestTransitionToSimplifying() { var strategy = new AbsoluteComplexityRegulationStrategy(10, 10.0); var eaStats = new EvolutionAlgorithmStatistics(); var popStats = new PopulationStatistics(); ComplexityRegulationMode mode; // The strategy should initialise to, and remain in, Complexifying mode // while mean population complexity is below the threshold. for (int i = 0; i < 11; i++) { eaStats.Generation = i; popStats.MeanComplexity = i; popStats.MeanComplexityHistory.Enqueue(i); mode = strategy.UpdateMode(eaStats, popStats); Assert.AreEqual(ComplexityRegulationMode.Complexifying, mode); } // The strategy should switch to simplifying mode when mean complexity // rises above the threshold. eaStats.Generation = 11; popStats.MeanComplexity = 10.01; popStats.MeanComplexityHistory.Enqueue(10.01); mode = strategy.UpdateMode(eaStats, popStats); Assert.AreEqual(ComplexityRegulationMode.Simplifying, mode); }
/// <summary> /// Update the graph data. /// </summary> /// <param name="eaStats">Evolution algorithm statistics object.</param> /// <param name="popStats">Population statistics object.</param> public virtual void UpdateData( EvolutionAlgorithmStatistics eaStats, PopulationStatistics popStats) { // Note. This method could be defined as abstract, but that would prevent the Window Forms UI designer from working; // therefore instead it is defined as virtual with no implementation. }
private ComplexityRegulationMode DetermineMode_WhileSimplifying( EvolutionAlgorithmStatistics eaStats, PopulationStatistics popStats) { // Currently simplifying. // Test if simplification (ongoing reduction in complexity) has stalled. // We allow simplification to progress for a few generations before testing of it has stalled, this allows // a lead in time for the effects of simplification to occur. // In addition we do not switch to complexifying if complexity is above the currently defined ceiling. if ( ((eaStats.Generation - _lastTransitionGeneration) > _minSimplifcationGenerations) && (popStats.MeanComplexity < _complexityCeiling) && ((popStats.MeanComplexityHistory.Mean - _prevMeanMovingAverage) >= 0.0)) { // Simplification has stalled; switch back to complexification. _currentMode = ComplexityRegulationMode.Complexifying; _lastTransitionGeneration = eaStats.Generation; _prevMeanMovingAverage = 0.0; } // else: otherwise remain in simplifying mode. // Update previous mean moving average complexity value. _prevMeanMovingAverage = popStats.MeanComplexityHistory.Mean; // Set a new complexity ceiling, relative to the current population complexity mean. _complexityCeiling = popStats.MeanComplexity + _relativeComplexityCeiling; return(_currentMode); }
/// <summary> /// Update the time series data. /// </summary> /// <param name="eaStats">Evolution algorithm statistics object.</param> /// <param name="popStats">Population statistics object.</param> public override void UpdateData( EvolutionAlgorithmStatistics eaStats, PopulationStatistics popStats) { _bestPpl.Add(eaStats.Generation, popStats.BestComplexity); _meanPpl.Add(eaStats.Generation, popStats.MeanComplexity); RefreshGraph(); }
/// <summary> /// Update the time series data. /// </summary> /// <param name="eaStats">Evolution algorithm statistics object.</param> /// <param name="popStats">Population statistics object.</param> public override void UpdateData( EvolutionAlgorithmStatistics eaStats, PopulationStatistics popStats) { _bestPpl.Add(eaStats.Generation, popStats.BestFitness.PrimaryFitness); _meanPpl.Add(eaStats.Generation, popStats.MeanFitness); RefreshGraph(); }
/// <summary> /// Determine the complexity regulation mode that the evolution algorithm search should be in given the /// provided evolution algorithm statistics object, and set the current mode to that mode. /// </summary> /// <param name="eaStats">Evolution algorithm statistics.</param> /// <param name="popStats">Population statistics.</param> /// <returns>The determined <see cref="ComplexityRegulationMode"/>.</returns> public ComplexityRegulationMode UpdateMode( EvolutionAlgorithmStatistics eaStats, PopulationStatistics popStats) { return(_currentMode switch { ComplexityRegulationMode.Complexifying => DetermineMode_WhileComplexifying(eaStats, popStats), ComplexityRegulationMode.Simplifying => DetermineMode_WhileSimplifying(eaStats, popStats), _ => throw new InvalidOperationException("Unexpected complexity regulation mode."), });
public void TestTransitionToComplexifying() { var strategy = new RelativeComplexityRegulationStrategy(10, 10.0); var eaStats = new EvolutionAlgorithmStatistics(); var popStats = new PopulationStatistics(); ComplexityRegulationMode mode; // Cause an immediate switch to into simplifying mode. int generation = 0; eaStats.Generation = generation++; popStats.MeanComplexity = 11.0; popStats.MeanComplexityHistory.Enqueue(11.0); mode = strategy.UpdateMode(eaStats, popStats); Assert.Equal(ComplexityRegulationMode.Simplifying, mode); // Reset the buffer that the moving average is calculated from; // This allows us to change the mean to below the threshold and for the // moving average to start rising immediately; that would ordinarily cause // an immediate switch back to complexifying mode, but that is prevented by // {minSimplifcationGenerations} being set to 10. popStats.MeanComplexityHistory.Clear(); for (int i = 0; i < 10; i++) { eaStats.Generation = generation++; popStats.MeanComplexity = 2.0; popStats.MeanComplexityHistory.Enqueue(2.0); mode = strategy.UpdateMode(eaStats, popStats); Assert.Equal(ComplexityRegulationMode.Simplifying, mode); } // Now that {minSimplifcationGenerations} have passed, the strategy should switch // back to complexifying mode. eaStats.Generation = generation++; popStats.MeanComplexity = 2.0; popStats.MeanComplexityHistory.Enqueue(2.0); mode = strategy.UpdateMode(eaStats, popStats); Assert.Equal(ComplexityRegulationMode.Complexifying, mode); // The threshold should have been set relative to the popStats.MeanComplexity (to 12). eaStats.Generation = generation++; popStats.MeanComplexity = 11.9; popStats.MeanComplexityHistory.Enqueue(11.9); mode = strategy.UpdateMode(eaStats, popStats); Assert.Equal(ComplexityRegulationMode.Complexifying, mode); eaStats.Generation = generation++; popStats.MeanComplexity = 12.01; popStats.MeanComplexityHistory.Enqueue(12.01); mode = strategy.UpdateMode(eaStats, popStats); Assert.Equal(ComplexityRegulationMode.Simplifying, mode); }
/// <summary> /// Determine the complexity regulation mode that the evolution algorithm search should be in given the /// provided evolution algorithm statistics object. /// </summary> /// <param name="eaStats">Evolution algorithm statistics.</param> /// <param name="popStats">Population statistics.</param> public ComplexityRegulationMode UpdateMode( EvolutionAlgorithmStatistics eaStats, PopulationStatistics popStats) { switch (_currentMode) { case ComplexityRegulationMode.Complexifying: return(DetermineMode_WhileComplexifying(eaStats, popStats)); case ComplexityRegulationMode.Simplifying: return(DetermineMode_WhileSimplifying(eaStats, popStats)); } throw new InvalidOperationException("Unexpected complexity regulation mode."); }
public void TestInitialisation() { var strategy = new AbsoluteComplexityRegulationStrategy(10, 10.0); var eaStats = new EvolutionAlgorithmStatistics(); var popStats = new PopulationStatistics(); // The strategy should initialise to, and remain in, Complexifying mode. for (int i = 0; i < 100; i++) { eaStats.Generation = i; ComplexityRegulationMode mode = strategy.UpdateMode(eaStats, popStats); Assert.AreEqual(ComplexityRegulationMode.Complexifying, mode); } }
private ComplexityRegulationMode DetermineMode_WhileComplexifying( EvolutionAlgorithmStatistics eaStats, PopulationStatistics popStats) { // Currently complexifying. // Test if the complexity ceiling has been reached. if (popStats.MeanComplexity > _complexityCeiling) { // Switch to simplifying mode. _currentMode = ComplexityRegulationMode.Simplifying; _lastTransitionGeneration = eaStats.Generation; _prevMeanMovingAverage = popStats.MeanComplexityHistory.Mean; } return(_currentMode); }