Data source for the SummaryGraphForm.
Example #1
0
        private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, SummaryDataSource[] dataSourceArray)
        {
            _graphPane            = zed.GraphPane;
            _graphPane.Title.Text = title;

            _graphPane.XAxis.Title.Text          = xAxisTitle;
            _graphPane.XAxis.MajorGrid.IsVisible = true;

            _graphPane.YAxis.Title.Text          = y1AxisTitle;
            _graphPane.YAxis.MajorGrid.IsVisible = true;

            _graphPane.Y2Axis.Title.Text          = y2AxisTitle;
            _graphPane.Y2Axis.MajorGrid.IsVisible = false;

            // Create point-pair lists and bind them to the graph control.
            int sourceCount = dataSourceArray.Length;

            _pointPlotArray = new PointPairList[sourceCount];
            for (int i = 0; i < sourceCount; i++)
            {
                SummaryDataSource ds = dataSourceArray[i];
                _pointPlotArray[i] = new PointPairList();

                Color   color   = _plotColorArr[i % 3];
                BarItem barItem = _graphPane.AddBar(ds.Name, _pointPlotArray[i], color);
                barItem.Bar.Fill = new Fill(color);
                _graphPane.BarSettings.MinClusterGap = 0;

                barItem.IsY2Axis = (ds.YAxis == 1);
            }
        }
Example #2
0
        private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, SummaryDataSource[] dataSourceArray)
        {
            _graphPane = zed.GraphPane;
            _graphPane.Title.Text = title;

			_graphPane.XAxis.Title.Text = xAxisTitle;
			_graphPane.XAxis.MajorGrid.IsVisible = true;

			_graphPane.YAxis.Title.Text = y1AxisTitle;
			_graphPane.YAxis.MajorGrid.IsVisible = true;

			_graphPane.Y2Axis.Title.Text = y2AxisTitle;
			_graphPane.Y2Axis.MajorGrid.IsVisible = false;

            // Create point-pair lists and bind them to the graph control.
            int sourceCount = dataSourceArray.Length;
            _pointPlotArray = new PointPairList[sourceCount];
            for(int i=0; i<sourceCount; i++)
            {
                SummaryDataSource ds = dataSourceArray[i];
                _pointPlotArray[i] =new PointPairList();

                Color color = _plotColorArr[i % 3];
                BarItem barItem = _graphPane.AddBar(ds.Name, _pointPlotArray[i], color);
                barItem.Bar.Fill = new Fill(color);
                _graphPane.BarSettings.MinClusterGap = 0;

                barItem.IsY2Axis = (ds.YAxis == 1);
            }
        }
        private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, SummaryDataSource[] dataSourceArray)
        {
            _graphPane = zed.GraphPane;
            _graphPane.Title.Text = title;

			_graphPane.XAxis.Title.Text = xAxisTitle;
			_graphPane.XAxis.MajorGrid.IsVisible = true;

			_graphPane.YAxis.Title.Text = y1AxisTitle;
			_graphPane.YAxis.MajorGrid.IsVisible = true;

			_graphPane.Y2Axis.Title.Text = y2AxisTitle;
			_graphPane.Y2Axis.MajorGrid.IsVisible = false;

            // Create point-pair lists and bind them to the graph control.
            int sourceCount = dataSourceArray.Length;
            _pointPlotArray = new PointPairList[sourceCount];
            for(int i=0; i<sourceCount; i++)
            {
                SummaryDataSource ds = dataSourceArray[i];
                _pointPlotArray[i] =new PointPairList();
                LineItem lineItem = _graphPane.AddCurve(ds.Name,  _pointPlotArray[i], ds.Color, SymbolType.None);
                lineItem.IsY2Axis = (ds.YAxis == 1);
            }
        }
Example #4
0
        private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, SummaryDataSource[] dataSourceArray)
        {
            _graphPane            = zed.GraphPane;
            _graphPane.Title.Text = title;

            _graphPane.XAxis.Title.Text          = xAxisTitle;
            _graphPane.XAxis.MajorGrid.IsVisible = true;

            _graphPane.YAxis.Title.Text          = y1AxisTitle;
            _graphPane.YAxis.MajorGrid.IsVisible = true;

            _graphPane.Y2Axis.Title.Text          = y2AxisTitle;
            _graphPane.Y2Axis.MajorGrid.IsVisible = false;

            // Create point-pair lists and bind them to the graph control.
            int sourceCount = dataSourceArray.Length;

            _pointPlotArray = new PointPairList[sourceCount];
            for (int i = 0; i < sourceCount; i++)
            {
                SummaryDataSource ds = dataSourceArray[i];
                _pointPlotArray[i] = new PointPairList();
                LineItem lineItem = _graphPane.AddCurve(ds.Name, _pointPlotArray[i], ds.Color, SymbolType.None);
                lineItem.IsY2Axis = (ds.YAxis == 1);
            }
        }
Example #5
0
        /// <summary>
        /// Construct the form with the provided details and data sources.
        /// </summary>
        public SummaryGraphForm(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle,
                         SummaryDataSource[] dataSourceArray, AbstractGenerationalAlgorithm<NeatGenome> ea)
        {
            InitializeComponent();

            this.Text = string.Format("SharpNEAT - {0}", title);
            _dataSourceArray = dataSourceArray;
            InitGraph(title, xAxisTitle, y1AxisTitle, y2AxisTitle, dataSourceArray);

            _ea = ea;
            if(null != ea) {
                _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
            }
        }
Example #6
0
        /// <summary>
        /// Handle update event from the evolution algorithm - update the view.
        /// </summary>
        public void _ea_UpdateEvent(object sender, EventArgs e)
        {
            // Switch execution to GUI thread if necessary.
            if (this.InvokeRequired)
            {
                // Must use Invoke(). BeginInvoke() will execute asynchronously and the evolution algorithm therefore
                // may have moved on and will be in an intermediate and indeterminate (between generations) state.
                this.Invoke(new MethodInvoker(delegate()
                {
                    if (this.IsDisposed)
                    {
                        return;
                    }

                    // Update plot points for each series in turn.
                    int sourceCount = _dataSourceArray.Length;
                    for (int i = 0; i < sourceCount; i++)
                    {
                        SummaryDataSource ds     = _dataSourceArray[i];
                        Point2DDouble[] pointArr = ds.GetPointArray();
                        PointPairList ppl        = _pointPlotArray[i];
                        EnsurePointPairListLength(ppl, pointArr.Length);

                        for (int j = 0; j < pointArr.Length; j++)
                        {
                            ppl[j].X = pointArr[j].X;
                            ppl[j].Y = pointArr[j].Y;
                        }
                    }

                    // Trigger graph to redraw.
                    zed.AxisChange();
                    Refresh();
                }));
            }
        }
Example #7
0
        private void specieChampFitnessByRankToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SummaryDataSource dsSpecieChampFitnessRank = new SummaryDataSource("Specie Fitness (Champs)", 0, Color.Red, delegate()
                                    {
                                        // Ensure temp working storage is ready.
                                        int specieCount = _ea.SpecieList.Count;
                                        if(null == _specieDataArray || _specieDataArray.Length != specieCount) {
                                            _specieDataArray = new double[specieCount];
                                        }

                                        // Copy specie fitnesses into the data array.
                                        for(int i=0; i<specieCount; i++) {
                                            _specieDataArray[i] = _ea.SpecieList[i].GenomeList[0].EvaluationInfo.Fitness;
                                        }

                                        // Build/create point array.
                                        UpdateRankedDataPoints(_specieDataArray, ref _specieDataPointArray);

                                        // Return plot points.
                                        return _specieDataPointArray;
                                    });

            SummaryDataSource dsSpecieMeanFitnessRank = new SummaryDataSource("Specie Fitness (Means)", 0, Color.Black, delegate()
                                    {
                                        // Ensure temp working storage is ready.
                                        int specieCount = _ea.SpecieList.Count;
                                        if(null == _specieDataArray || _specieDataArray.Length != specieCount) {
                                            _specieDataArray = new double[specieCount];
                                        }

                                        // Copy specie fitnesses into the data array.
                                        for(int i=0; i<specieCount; i++) {
                                            _specieDataArray[i] = _ea.SpecieList[i].CalcMeanFitness();
                                        }

                                        // Build/create point array.
                                        UpdateRankedDataPoints(_specieDataArray, ref _specieDataPointArray);

                                        // Return plot points.
                                        return _specieDataPointArray;
                                    });


            // Create form.
            SummaryGraphForm graphForm = new SummaryGraphForm("Specie Fitness by Rank", "Species", "Fitness", string.Empty,
                                                 new SummaryDataSource[] {dsSpecieChampFitnessRank, dsSpecieMeanFitnessRank}, _ea);
            _summaryGraphFormList.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)
            {
                _summaryGraphFormList.Remove(senderObj as SummaryGraphForm);
                specieChampFitnessByRankToolStripMenuItem.Enabled = true;
            });

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

            // Show the form.
            graphForm.Show(this);
        }
Example #8
0
        private void specieSizeByRankToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SummaryDataSource dsSpecieSizeRank = new SummaryDataSource("Specie Size", 0, Color.Red, delegate()
                                    {
                                        // Ensure temp working storage is ready.
                                        int specieCount = _ea.SpecieList.Count;
                                        if(null == _specieDataArrayInt || _specieDataArrayInt.Length != specieCount) {
                                            _specieDataArrayInt = new int[specieCount];
                                        }

                                        // Copy specie sizes into _specieSizeArray.
                                        for(int i=0; i<specieCount; i++) {
                                            _specieDataArrayInt[i] = _ea.SpecieList[i].GenomeList.Count;
                                        }

                                        // Build/create _specieSizePointArray from the _specieSizeArray.
                                        UpdateRankedDataPoints(_specieDataArrayInt, ref _specieDataPointArrayInt);

                                        // Return plot points.
                                        return _specieDataPointArrayInt;
                                    });
            // Create form.
            SummaryGraphForm graphForm = new SummaryGraphForm("Specie Size by Rank", "Species (largest to smallest)", "Size", string.Empty,
                                                 new SummaryDataSource[] {dsSpecieSizeRank}, _ea);
            _summaryGraphFormList.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)
            {
                _summaryGraphFormList.Remove(senderObj as SummaryGraphForm);
                specieSizeByRankToolStripMenuItem.Enabled = true;
            });

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

            // Show the form.
            graphForm.Show(this);
        }
Example #9
0
        private void genomeComplexityDistributionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SummaryDataSource dsGenomeComplexityDist = new SummaryDataSource("Genome Complexity Distribution", 0, Color.Red, delegate()
                                    {
                                        // Ensure temp working storage is ready.
                                        int genomeCount = _ea.GenomeList.Count;
                                        if(null == _genomeDataArray || _genomeDataArray.Length != genomeCount) {
                                            _genomeDataArray = new double[genomeCount];
                                        }

                                        // Copy genome fitness values into the data array.
                                        for(int i=0; i<genomeCount; i++) {
                                            _genomeDataArray[i] = _ea.GenomeList[i].Complexity;
                                        }

                                        // Calculate a frequency distribution and retrieve it as an array of plottable points.
                                        Point2DDouble[] pointArr = CalcDistributionDataPoints(_genomeDataArray);

                                        // Return plot points.
                                        return pointArr;
                                    });
            // Create form.
            SummaryGraphForm graphForm = new SummaryGraphForm("Genome Complexity Distribution", "Complexity", "Frequency", string.Empty,
                                                 new SummaryDataSource[] {dsGenomeComplexityDist}, _ea);
            _summaryGraphFormList.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)
            {
                _summaryGraphFormList.Remove(senderObj as SummaryGraphForm);
                genomeComplexityDistributionToolStripMenuItem.Enabled = true;
            });

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

            // Show the form.
            graphForm.Show(this);
        }
Example #10
0
        private void specieFitnessDistributionsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SummaryDataSource dsSpecieChampFitnessDist = new SummaryDataSource("Specie Fitness Distribution (Champ)", 0, Color.Red, delegate()
                                    {
                                        // Ensure temp working storage is ready.
                                        int specieCount = _ea.SpecieList.Count;
                                        if(null == _specieDataArray || _specieDataArray.Length != specieCount) {
                                            _specieDataArray = new double[specieCount];
                                        }

                                        // Copy specie sizes into _specieSizeArray.
                                        for(int i=0; i<specieCount; i++) {
                                            _specieDataArray[i] = _ea.SpecieList[i].GenomeList[0].EvaluationInfo.Fitness;
                                        }

                                        // Calculate a frequency distribution and retrieve it as an array of plottable points.
                                        Point2DDouble[] pointArr = CalcDistributionDataPoints(_specieDataArray);

                                        // Return plot points.
                                        return pointArr;
                                    });

            SummaryDataSource dsSpecieMeanFitnessDist = new SummaryDataSource("Specie Fitness Distribution (Mean)", 0, Color.Black, delegate()
                                    {
                                        // Ensure temp working storage is ready.
                                        int specieCount = _ea.SpecieList.Count;
                                        if(null == _specieDataArray || _specieDataArray.Length != specieCount) {
                                            _specieDataArray = new double[specieCount];
                                        }

                                        // Copy specie sizes into _specieSizeArray.
                                        for(int i=0; i<specieCount; i++) {
                                            _specieDataArray[i] = _ea.SpecieList[i].CalcMeanFitness();
                                        }

                                        // Calculate a frequency distribution and retrieve it as an array of plottable points.
                                        Point2DDouble[] pointArr = CalcDistributionDataPoints(_specieDataArray);

                                        // Return plot points.
                                        return pointArr;
                                    });
            // Create form.
            SummaryGraphForm graphForm = new SummaryGraphForm("Specie Fitness Distribution", "Fitness", "Frequency", string.Empty,
                                                 new SummaryDataSource[] {dsSpecieChampFitnessDist, dsSpecieMeanFitnessDist}, _ea);
            _summaryGraphFormList.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)
            {
                _summaryGraphFormList.Remove(senderObj as SummaryGraphForm);
                specieFitnessDistributionsToolStripMenuItem.Enabled = true;
            });

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

            // Show the form.
            graphForm.Show(this);
        }
Example #11
0
        private void genomeComplexityByRankToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SummaryDataSource dsGenomeComplexityRank = new SummaryDataSource("Genome Complexity", 0, Color.Red, delegate()
                                    {
                                        // Ensure temp working storage is ready.
                                        int genomeCount = _ea.GenomeList.Count;
                                        if(null == _genomeDataArray || _genomeDataArray.Length != genomeCount) {
                                            _genomeDataArray = new double[genomeCount];
                                        }

                                        // Copy genome complexity values into the data array.
                                        for(int i=0; i<genomeCount; i++) {
                                            _genomeDataArray[i] = _ea.GenomeList[i].Complexity;
                                        }

                                        // Build/create point array.
                                        UpdateRankedDataPoints(_genomeDataArray, ref _genomeDataPointArray);

                                        // Return plot points.
                                        return _genomeDataPointArray;
                                    });
            // Create form.
            SummaryGraphForm graphForm = new SummaryGraphForm("Genome Complexity by Rank", "Genomes", "Complexity", string.Empty,
                                                 new SummaryDataSource[] {dsGenomeComplexityRank}, _ea);
            _summaryGraphFormList.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)
            {
                _summaryGraphFormList.Remove(senderObj as SummaryGraphForm);
                genomeComplexityByRankToolStripMenuItem.Enabled = true;
            });

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

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