Example #1
0
 /// <summary>
 /// Calculates the metrics for a generation.
 /// </summary>
 private void CalculateStats(GeneticEnvironment geneticEnvironment, int generationIndex)
 {
     foreach (Metric metric in this.sortedMetrics)
     {
         metric.Calculate(geneticEnvironment, generationIndex);
     }
 }
Example #2
0
 /// <summary>
 /// Calculates the metrics for the <paramref name="environment"/>.
 /// </summary>
 public static void Calculate(this Metric metric, GeneticEnvironment environment, int generationIndex)
 {
     foreach (Population population in environment.Populations)
     {
         ObservableCollection <MetricResult> populationStats = metric.GetResults(population.Index);
         MetricResult result = new MetricResult(generationIndex, population.Index, metric.GetResultValue(population), metric);
         populationStats.Add(result);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="EnvironmentFitnessEvaluatedEventArgs"/> class.
        /// </summary>
        /// <param name="environment">The <see cref="GeneticEnvironment"/> being used by the <see cref="GeneticAlgorithm"/>.</param>
        /// <param name="generationIndex">The index of the generation that has just been created.</param>
        /// <exception cref="ArgumentNullException"><paramref name="environment"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="generationIndex"/> is less than zero.</exception>
        public EnvironmentFitnessEvaluatedEventArgs(GeneticEnvironment environment, int generationIndex)
        {
            if (generationIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(generationIndex), generationIndex, Resources.ErrorMsg_InvalidGenerationIndex);
            }

            this.Environment     = environment ?? throw new ArgumentNullException(nameof(environment));
            this.GenerationIndex = generationIndex;
        }
Example #4
0
 /// <summary>
 /// Handles the event when the fitness of an environment has been evaluated.
 /// </summary>
 /// <param name="environment">The environment which has had its fitness evaluated..</param>
 /// <param name="generationIndex">Index value of the current generation in the environment.</param>
 protected virtual void OnFitnessEvaluated(GeneticEnvironment environment, int generationIndex)
 {
 }