Data source for the TimeSeriesGraphForm.
        private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, TimeSeriesDataSource[] 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 RollingPointPairList[sourceCount];
            for(int i=0; i<sourceCount; i++)
            {
                TimeSeriesDataSource ds = dataSourceArray[i];
                _pointPlotArray[i] = new RollingPointPairList(ds.HistoryLength);
                LineItem lineItem = _graphPane.AddCurve(ds.Name,  _pointPlotArray[i], ds.Color, SymbolType.None);
                lineItem.IsY2Axis = (ds.YAxis == 1);
            }
        }
        private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, TimeSeriesDataSource[] 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 RollingPointPairList[sourceCount];
            for(int i=0; i<sourceCount; i++)
            {
                TimeSeriesDataSource ds = dataSourceArray[i];
                _pointPlotArray[i] = new RollingPointPairList(ds.HistoryLength);
                LineItem lineItem = _graphPane.AddCurve(ds.Name,  _pointPlotArray[i], ds.Color, SymbolType.None);
                lineItem.IsY2Axis = (ds.YAxis == 1);
            }
        }
        /// <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;
                    }

                    // For each series, generate a point and add it to that series' point-pair list.
                    int sourceCount = _dataSourceArray.Length;
                    for(int i=0; i<sourceCount; i++)
                    {
                        TimeSeriesDataSource ds = _dataSourceArray[i];
                        Point2DDouble point  = ds.GetPoint();
                        _pointPlotArray[i].Add(point.X, point.Y);
                    }

                    // Trigger graph to redraw.
                    zed.AxisChange();
                    Refresh();
                }));
            }
        }
        /// <summary>
        /// Construct the form with the provided details and data sources.
        /// </summary>
        public TimeSeriesGraphForm(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle,
                         TimeSeriesDataSource[] dataSourceArray, AbstractGenerationalAlgorithm<NeatGenome> ea)
        {
            InitializeComponent();

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

            _ea = ea;
            if(null != ea) {
                _ea.UpdateEvent += new EventHandler(_ea_UpdateEvent);
            }
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }