Exemplo n.º 1
0
        private void bttnEvaluate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var trainingFile = new DataFile(ApplicationSingleton.Instance.Config);
                trainingFile.LoadExcel(ApplicationSingleton.Instance.Config.EvaluationFile);
                double[][] evalInput = trainingFile.GenerateInputData();
                var evalOutput = new double[evalInput.Length][];

                var genome = ApplicationSingleton.Instance.GenomePopulation.BestGenome;
                double sc = ApplicationSingleton.Instance.Config.Model.Score(genome, evalInput,
                    trainingFile.GenerateIdealData());

                for (int row = 0; row < evalInput.Length; row++)
                {
                    double[] output = ApplicationSingleton.Instance.Config.Model.Compute(evalInput[row], genome);
                    for (int col = 0; col < output.Length; col++)
                    {
                        evalOutput[row] = output;
                    }
                }

                trainingFile.WriteExcel(ApplicationSingleton.Instance.Config.EvaluationOutputFile, evalOutput);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name);
            }
        }
Exemplo n.º 2
0
        private void bttnTrain_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var trainingFile = new DataFile(ApplicationSingleton.Instance.Config);
                trainingFile.LoadExcel(ApplicationSingleton.Instance.Config.TrainingFile);
                double[][] trainingInput = trainingFile.GenerateInputData();
                double[][] trainingIdeal = trainingFile.GenerateIdealData();

                ApplicationSingleton.Instance.Train = new GeneticTraining(
                    ApplicationSingleton.Instance.GenomePopulation,
                    trainingInput,
                    trainingIdeal);
                ApplicationSingleton.Instance.Train.Start();
                ApplicationSingleton.Instance.Train.AddListener(this);
                UpdateButtons();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name);
            }
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        private void bttnTrain_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var trainingFile = new DataFile(ApplicationSingleton.Instance.Config);
                trainingFile.LoadExcel(ApplicationSingleton.Instance.Config.TrainingFile);
                double[][] trainingInput = trainingFile.GenerateInputData();
                double[][] trainingIdeal = trainingFile.GenerateIdealData();

                ApplicationSingleton.Instance.Train = new GeneticTraining(
                    ApplicationSingleton.Instance.GenomePopulation,
                    trainingInput,
                    trainingIdeal);
                ApplicationSingleton.Instance.Train.Start();
                ApplicationSingleton.Instance.Train.AddListener(this);
                UpdateButtons();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name);
            }
        }