Form for displaying a graph plot of time series data (e.g. best genome fitness per generation).
Inheritance: System.Windows.Forms.Form
Esempio n. 1
0
        private void complexityBestMeansToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Create data sources.
            TimeSeriesDataSource dsBestCmplx = new TimeSeriesDataSource("Best", TimeSeriesDataSource.DefaultHistoryLength, 0, Color.Red, delegate() 
                                                            {
                                                                return new Point2DDouble(_ea.CurrentGeneration, _ea.CurrentChampGenome.Complexity);
                                                            });

            TimeSeriesDataSource dsMeanCmplx = new TimeSeriesDataSource("Mean", TimeSeriesDataSource.DefaultHistoryLength, 0, Color.Black, delegate() 
                                                            {
                                                                return new Point2DDouble(_ea.CurrentGeneration, _ea.Statistics._meanComplexity);
                                                            });

            TimeSeriesDataSource dsMeanCmplxMA = new TimeSeriesDataSource("Mean (Moving Average)", TimeSeriesDataSource.DefaultHistoryLength, 0, Color.Orange, delegate() 
                                                            {
                                                                return new Point2DDouble(_ea.CurrentGeneration, _ea.Statistics._complexityMA.Mean);
                                                            });

            // Create form.
            TimeSeriesGraphForm graphForm = new TimeSeriesGraphForm("Complexity (Best and Mean)", "Generation", "Complexity", string.Empty,
                                                 new TimeSeriesDataSource[] {dsBestCmplx, dsMeanCmplx, dsMeanCmplxMA}, _ea);
            _timeSeriesGraphFormList.Add(graphForm);

            // Attach a event handler to update this main form when the graph form is closed.
            graphForm.FormClosed += new FormClosedEventHandler(delegate(object senderObj, FormClosedEventArgs eArgs)
            {
                _timeSeriesGraphFormList.Remove(senderObj as TimeSeriesGraphForm);
                complexityBestMeansToolStripMenuItem.Enabled = true;
            });

            // Prevent creating more then one instance fo the form.
            complexityBestMeansToolStripMenuItem.Enabled = false;

            // Show the form.
            graphForm.Show(this);
        }
Esempio n. 2
0
        private void evaluationsPerSecToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Create data sources.
            TimeSeriesDataSource dsEvalsPerSec= new TimeSeriesDataSource("Evals Per Sec", TimeSeriesDataSource.DefaultHistoryLength, 0, Color.Black, delegate() 
                                                            {
                                                                return new Point2DDouble(_ea.CurrentGeneration, _ea.Statistics._evaluationsPerSec);
                                                            });
            // Create form.
            TimeSeriesGraphForm graphForm = new TimeSeriesGraphForm("Evaluations Per Second", "Generation", "Evaluations", string.Empty,
                                                 new TimeSeriesDataSource[] {dsEvalsPerSec}, _ea);
            _timeSeriesGraphFormList.Add(graphForm);

            // Attach a event handler to update this main form when the graph form is closed.
            graphForm.FormClosed += new FormClosedEventHandler(delegate(object senderObj, FormClosedEventArgs eArgs)
            {
                _timeSeriesGraphFormList.Remove(senderObj as TimeSeriesGraphForm);
                evaluationsPerSecToolStripMenuItem.Enabled = true;
            });

            // Prevent creating more then one instance fo the form.
            evaluationsPerSecToolStripMenuItem.Enabled = false;

            // Show the form.
            graphForm.Show(this);
        }
Esempio n. 3
0
        private void fitnessBestMeansToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Create data sources.
            List<TimeSeriesDataSource> _dsList = new List<TimeSeriesDataSource>();


            _dsList.Add(new TimeSeriesDataSource("Best", TimeSeriesDataSource.DefaultHistoryLength, 0, Color.Red, delegate() 
                                                            {
                                                                return new Point2DDouble(_ea.CurrentGeneration, _ea.Statistics._maxFitness);
                                                            }));

            _dsList.Add(new TimeSeriesDataSource("Mean", TimeSeriesDataSource.DefaultHistoryLength, 0, Color.Black, delegate() 
                                                            {
                                                                return new Point2DDouble(_ea.CurrentGeneration, _ea.Statistics._meanFitness);
                                                            }));

            _dsList.Add(new TimeSeriesDataSource("Best (Moving Average)", TimeSeriesDataSource.DefaultHistoryLength, 0, Color.Orange, delegate() 
                                                            {
                                                                return new Point2DDouble(_ea.CurrentGeneration, _ea.Statistics._bestFitnessMA.Mean);
                                                            }));

            // Create a data sources for any auxiliary fitness info.
            AuxFitnessInfo[] auxFitnessArr = _ea.CurrentChampGenome.EvaluationInfo.AuxFitnessArr;
            if(null != auxFitnessArr)
            {
                for(int i=0; i<auxFitnessArr.Length; i++)
                {
                    // 'Capture' the value of i in a locally defined variable that has scope specific to each delegate creation (below). If capture 'i' instead then it will always have
                    // its last value in each delegate (which happens to be one past the end of the array).
                    int ii = i;
                    _dsList.Add(new TimeSeriesDataSource(_ea.CurrentChampGenome.EvaluationInfo.AuxFitnessArr[i]._name, TimeSeriesDataSource.DefaultHistoryLength, 0, _plotColorArr[i % _plotColorArr.Length], delegate() 
                                                                    {   
                                                                        return new Point2DDouble(_ea.CurrentGeneration, _ea.CurrentChampGenome.EvaluationInfo.AuxFitnessArr[ii]._value);
                                                                    }));
                }
            }

            // Create form.
            TimeSeriesGraphForm graphForm = new TimeSeriesGraphForm("Fitness (Best and Mean)", "Generation", "Fitness", string.Empty, _dsList.ToArray(), _ea);
            _timeSeriesGraphFormList.Add(graphForm);

            // Attach a event handler to update this main form when the graph form is closed.
            graphForm.FormClosed += new FormClosedEventHandler(delegate(object senderObj, FormClosedEventArgs eArgs)
            {
                _timeSeriesGraphFormList.Remove(senderObj as TimeSeriesGraphForm);
                fitnessBestMeansToolStripMenuItem.Enabled = true;
            });

            // Prevent creating more then one instance fo the form.
            fitnessBestMeansToolStripMenuItem.Enabled = false;

            // Show the form.
            graphForm.Show(this);
        }