Exemple #1
0
 private void EvaluateOne(TGenome genome, TPhenome phenome, ParallelEvaluationParameters parameters)
 {
     if (null == phenome)
     {   // Non-viable genome.
         System.Diagnostics.Debug.WriteLine("Non-viable phenome found");
         genome.EvaluationInfo.SetFitness(0.0);
         genome.EvaluationInfo.AuxFitnessArr = null;
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("Evaluate one calls pseudoevaluator.");
         FitnessInfo fitnessInfo = _phenomeEvaluator.Evaluate(phenome, parameters);
         // We don't want to update fitness in this way in the website-based project.
         // See evolution algorithm.
         //genome.EvaluationInfo.SetFitness(fitnessInfo._fitness);
         //genome.EvaluationInfo.AuxFitnessArr = fitnessInfo._auxFitnessArr;
     }
 }
Exemple #2
0
        /// <summary>
        /// The phenomes have all been found before, because they require accessing the decoder, and this
        /// causes trouble with parallelization. genomeToPort is introduced because genomeList.IndexOf(genome)
        /// was returning out of range exceptions
        /// </summary>
        private void EvaluateList(Dictionary <TGenome, TPhenome> genomeToPhenome, Dictionary <string, int> genomeToPort, string userName)
        {
            List <TGenome> genomeList = new List <TGenome>(genomeToPhenome.Keys);

            Parallel.ForEach(genomeList, _parallelOptions, delegate(TGenome genome)
            {
                try
                {
                    // random wait?
                    TPhenome phenome = genomeToPhenome[genome];
                    int genomeIndex  = genomeToPort[genome.CandidateName];
                    ParallelEvaluationParameters parameters = new ParallelEvaluationParameters(genome.CandidateName, userName, genomeIndex);
                    EvaluateOne(genome, phenome, parameters);
                }
                catch (System.Exception ex)
                {
                    string error = "Exception occurred in parallel evaluation: skipping evaluation! " + ex.Message;
                    System.Diagnostics.Debug.WriteLine(error);
                }
            });
        }