Ejemplo n.º 1
0
        private void bttnGeneratePop_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (new WaitCursor())
                {
                    var pop = new Population();
                    pop.Init(ApplicationSingleton.Instance.Config);
                    ApplicationSingleton.Instance.GenomePopulation = pop;
                    pop.Generate();
                    lblBestScore.Content = ApplicationSingleton.Instance.GenomePopulation.BestGenome.Score;

                    var trainingFile = new DataFile(ApplicationSingleton.Instance.Config);
                    trainingFile.LoadExcel(ApplicationSingleton.Instance.Config.TrainingFile);
                    double[][] trainingInput = trainingFile.GenerateInputData();
                    double[][] trainingIdeal = trainingFile.GenerateIdealData();

                    pop.ScoreAll(trainingInput, trainingIdeal);

                    UpdateButtons();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Construct the trainer.
 /// </summary>
 /// <param name="population">The population to train.</param>
 /// <param name="trainingInput">The input.</param>
 /// <param name="trainingIdeal">The expected output.</param>
 public GeneticTraining(Population population, double[][] trainingInput, double[][] trainingIdeal)
 {
     _population = population;
     _trainingInput = trainingInput;
     _trainingIdeal = trainingIdeal;
     _trainingStopEvent = new AutoResetEvent(false);
 }