Exemplo n.º 1
0
        public void ProgressUpdate(KeyValuePair <int, AccordGenetic.Wrap.Result> kvp, ApproximationWrap wrap)
        {
            // update info

            var error = wrap.EvaluateError();

            chart.UpdateDataSeries("solution", kvp.Value.Output);
            SetText(currentIterationBox, kvp.Key.ToString());

            SetText(currentErrorBox, error.Prediction.ToString("F3"));
            SetText(solutionBox, kvp.Value.BestSolution.ToString());
        }
        public void ProgressUpdate(KeyValuePair <int, AccordGenetic.Wrap.Result> kvp, ApproximationWrap wrap)
        {
            // update info

            if (++cnt % 200 == 1)
            {
                var error = wrap.EvaluateError();
                //chart.UpdateDataSeries("solution", kvp.Value.Output);
                var list = new List <DataPoint>();

                for (int i = 0; i < kvp.Value.Output.GetLength()[0] - 1; i++)
                {
                    list.Add(new DataPoint(kvp.Value.Output[i, 0], kvp.Value.Output[i, 1]));
                }

                this.Dispatcher?.InvokeAsync(() =>
                {
                    PlotView.Model ??= new PlotModel {
                        Title = "Genetic"
                    };
                    PlotView.Model.Series.Add(

                        new LineSeries {
                        ItemsSource = list
                    }
                        );
                    PlotView.Model.InvalidatePlot(true);

                    Iterations.Value = kvp.Key;
                    Error.Text       = error.Prediction.ToString("F3");
                    Solution.Text    = kvp.Value.BestSolution;
                });
            }
        }