Esempio n. 1
0
 internal void SetState(GAF.Population population)
 {
     //update member variables from population
     this.PopulationSize        = population.PopulationSize;
     this.ChromosomeLength      = population.ChromosomeLength;
     this.EvaluateInParallel    = population.EvaluateInParallel;
     this.LinearlyNormalised    = population.LinearlyNormalised;
     this.ReEvaluateAll         = population.ReEvaluateAll;
     this.ParentSelectionMethod = (Api.ParentSelectionMethod)population.ParentSelectionMethod;
 }
Esempio n. 2
0
        internal static PopulationState GetState(GAF.Population population)
        {
            var state = new PopulationState();

            state.EvaluateInParallel    = population.EvaluateInParallel;
            state.ReEvaluateAll         = population.ReEvaluateAll;
            state.ParentSelectionMethod = (Api.ParentSelectionMethod)population.ParentSelectionMethod;
            state.LinearlyNormalised    = population.LinearlyNormalised;
            state.PopulationSize        = population.PopulationSize;
            state.ChromosomeLength      = population.ChromosomeLength;
            return(state);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:GAF.Api.PopulationHistoryItem"/> class.
        /// </summary>
        /// <param name="population">Population.</param>
        public PopulationHistoryItem(GAF.Population population, int sourceGeneration)
        {
            if (population == null)
            {
                throw new ArgumentNullException("population");
            }
            if (population.Solutions == null)
            {
                throw new NullReferenceException("The population.Solutions property is null.");
            }

            SolutionData = new List <Chromosome> ();

            foreach (var solution in population.Solutions)
            {
                SolutionData.Add(new Chromosome(solution.ToString(), solution.Fitness));
            }
            SourceGeneration = sourceGeneration;
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a population to the history.
        /// </summary>
        /// <returns>The population.</returns>
        /// <param name="population">Population.</param>
        public void AddPopulation(GAF.Population population, int sourceGeneration)
        {
            if (population == null)
            {
                throw new ArgumentNullException("population");
            }
            if (population.Solutions == null)
            {
                throw new NullReferenceException("The population.Solutions property is null.");
            }


            var populationHistoryItem = new PopulationHistoryItem(population, sourceGeneration);

            PopulationHistoryItems.Add(populationHistoryItem);

            if (PopulationHistoryItems.Count > _populationHistorySize)
            {
                PopulationHistoryItems.RemoveAt(0);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Derive statistics from the specified population.
        /// The includeHammingDistance parameter causes the class to calculate the
        /// Hamming Distance of the population. This should be used with care as setting
        /// this property to true could have performance implecations.
        /// </summary>
        /// <param name="population"></param>
        public void ProcessPopulation(GAF.Population population, int generation)
        {
            if (population == null)
            {
                throw new ArgumentNullException(nameof(population));
            }

            if (population.Solutions == null || !population.Solutions.Any())
            {
                throw new ArgumentException("The specified population has no solutions");
            }

            _population       = population;
            _populationSize   = population.PopulationSize;
            _chromosomeLength = population.ChromosomeLength;

            var geneType = _population.Solutions [0].Genes [0].GeneType;

            this.PopulationHistory.AddPopulation(population, generation);
            RaisePropertyChangedEvent("PopulationHistory");

            //do the basics ??
            Process(geneType);
        }
Esempio n. 6
0
 /// <summary>
 /// Creates the GenerationComplete message.
 /// </summary>
 /// <value>The population.</value>
 public string CreateGenerationCompleteMessage(GAF.Population currentPopulation, int currentGeneration, long evaluations)
 {
     return(((IGafLabConsumerFunctions)LoadedAssemblyInstance).CreateGenerationCompleteMessage(currentPopulation, currentGeneration, evaluations));
 }