protected override void PreFilterProperties(IDictionary properties) { base.PreFilterProperties(properties); #if NOTDEF // We add a design-time property called TrackSelection that is used to track // the active selection. If the user sets this to true (the default), then // we will listen to selection change events and update the control's active // control to point to the current primary selection. GA ga = (GA)Component; if (ga.EncodingType == EncodingType.Custom) { properties.Remove("ChromosomeLength"); } if (ga.EncodingType != EncodingType.Integer) { properties.Remove("MaxIntValue"); properties.Remove("MinIntValue"); } if (ga.EncodingType != EncodingType.Real) { properties.Remove("MaxDoubleValue"); properties.Remove("MinDoubleValue"); } // properties["TrackSelection"] = TypeDescriptor.CreateProperty( // this.GetType(), // the type this property is defined on // "TrackSelection", // the name of the property // typeof(bool), // the type of the property // new Attribute[] {CategoryAttribute.Design}); // attributes #endif }
/* * mode - most frequently occuring score. * median - midpoint of distribution, above which have of the scores fall, and below * which the other half fall. */ /// <summary> /// Creates a PopulationSummary from a Population. /// </summary> /// <param name="ga">The GA.</param> /// <param name="Population">The Population for which the /// PopulationSummary will provide summary information. /// </param> public PopulationSummary(GA ga, Population Population) { double totalObjective; lowestObjective = System.Double.MaxValue; highestObjective = System.Double.MinValue; totalObjective = 0; foreach (Chromosome c in Population.Chromosomes) { totalObjective += c.RawObjective; if (c.RawObjective < LowestObjective) { lowestObjective = c.RawObjective; if (ga.ObjectiveType == ObjectiveType.MinimizeObjective) { bestChromosome = c; } } if (c.RawObjective > HighestObjective) { highestObjective = c.RawObjective; if (ga.ObjectiveType == ObjectiveType.MaximizeObjective) { bestChromosome = c; } } } meanObjective = totalObjective / Population.Chromosomes.Length; // // Variance is the average squared deviation from the mean. // Standard Deviation is just the square root of this. // double sum = 0; foreach (Chromosome c in Population.Chromosomes) { double deviation; double squaredDeviation; deviation = c.RawObjective - meanObjective; squaredDeviation = deviation * deviation; sum += squaredDeviation; } variance = sum / (Population.Chromosomes.Length - 1); standardDeviation = Math.Sqrt(variance); }
/// <summary> /// Creates a new Population of Chromosomes. /// </summary> /// <param name="ga">The GA.</param> /// <param name="populationSize">The size of the population.</param> public Population(GA ga, int populationSize) { this.ga = ga; this.populationSize = populationSize; chromosomes = new Chromosome[PopulationSize]; }