コード例 #1
0
        private void AddVolatilityCursorCurves()
        {
            GraphPane pane = volatilityGraph.GraphPane;

            if (volatility_mcurve.Count == 0)
            {
                return;
            }

            int    i = ((LineItem)volatility_mcurve[0]).NPts / 2;
            double x = ((LineItem)volatility_mcurve[0]).Points[i].X;
            double y = ((LineItem)volatility_mcurve[0]).Points[i].Y;

            // graph marker symbol
            volatility_cursor_symb = pane.AddCurve("Cursor", null, Config.Color.GraphCurveForeColor(0), SymbolType.Circle);
            volatility_cursor_symb.AddPoint(new PointPair(x, y));
            volatility_cursor_symb.Symbol.Size = 7;
            volatility_cursor_symb.Symbol.Fill = new Fill(Config.Color.GraphCurveForeColor(0));
            volatility_cursor_symb.Line.Style  = System.Drawing.Drawing2D.DashStyle.Dot;

            volatility_cursor_line = pane.AddCurve(string.Empty, null, Config.Color.GraphCurveForeColor(0), SymbolType.None);
            volatility_cursor_line.AddPoint(new PointPair(x, pane.YAxis.Scale.Min));
            volatility_cursor_line.AddPoint(new PointPair(x, pane.YAxis.Scale.Max));
            volatility_cursor_line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
        }
コード例 #2
0
        /// <summary>
        /// Uodate GP Model chart when data or GP model is changed
        /// </summary>
        /// <param name="y">output value</param>
        /// <param name="gpModel"> indicator is it about GPMOdel or Data Point</param>
        public void UpdateChartDataPoint(double[][] y, bool gpModel = true)
        {
            if (this.zedModel.GraphPane == null || y == null)
            {
                return;
            }

            LineItem li = null;

            if (gpModel)//ann calculated data
            {
                li = gpModelLine;
                li.Clear();
                for (int i = 0; i < y[0].Length; i++)
                {
                    li.AddPoint(i + 1, y[0][i]);
                }
            }

            else//experimental data
            {
                li = gpDataLine;
                li.Clear();
                for (int i = 0; i < y.Length; i++)
                {
                    li.AddPoint(i + 1, y[i][1]);
                }
            }


            this.zedModel.GraphPane.AxisChange(this.CreateGraphics());
            this.zedModel.Refresh();
        }
コード例 #3
0
        private void Training_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            try
            {
                //clear prev. state
                trainingMinibatchGraph.GraphPane.CurveList.Clear();
                trainingDatasetsGraph.GraphPane.CurveList.Clear();

                //force to update the control
                this.trainingMinibatchGraph.RestoreScale(trainingMinibatchGraph.GraphPane);
                this.trainingDatasetsGraph.RestoreScale(trainingDatasetsGraph.GraphPane);

                if (this.DataContext == null || !(this.DataContext is MLConfigController))
                {
                    return;
                }
                var mlConfig = this.DataContext as MLConfigController;

                //
                mlConfig.UpdateTrainingtGraphs = UpdateGraphs;

                //prepage graph
                prepareGraphPanel1();
                prepareGraphPanel2();
                //
                preparesSeriesGraph1();
                bool isValidDefined = mlConfig.IsValidationSetDefined();
                preparesSeriesGraph2(isValidDefined);

                //
                for (int i = 0; i < mlConfig.TrainingProgress.MBLossValue.Count; i++)
                {
                    lossMinibatchSerie.AddPoint(mlConfig.TrainingProgress.MBLossValue[i]);
                    evalMinibatchSerie.AddPoint(mlConfig.TrainingProgress.MBEvaluationValue[i]);
                }
                for (int i = 0; i < mlConfig.TrainingProgress.TrainEvalValue.Count; i++)
                {
                    evalTrainingSerie.AddPoint(mlConfig.TrainingProgress.TrainEvalValue[i]);
                    evalValidationSerie.AddPoint(mlConfig.TrainingProgress.ValidationEvalValue[i]);
                }

                //Refresh the charts
                trainingMinibatchGraph.RestoreScale(trainingMinibatchGraph.GraphPane);
                trainingDatasetsGraph.RestoreScale(trainingDatasetsGraph.GraphPane);
            }
            catch (Exception ex)
            {
                var ac = App.Current.MainWindow.DataContext as AppController;
                if (ac != null)
                {
                    ac.ReportException(ex);
                }
            }
        }
コード例 #4
0
 public CurveInfo(string modifiedSequence, Color peptideColor, double retentionTime, float intensity)
 {
     Curve = new LineItem(string.Empty, new PointPairList(), peptideColor, SymbolType.None)
     {
         Line  = { Fill = new Fill(Color.FromArgb(80, peptideColor)), Width = 1, IsAntiAlias = true },
         Label = { IsVisible = false }
     };
     Curve.AddPoint(retentionTime - ChromatogramLoadingStatus.TIME_RESOLUTION, 0);
     Curve.AddPoint(retentionTime, intensity);
     Curve.AddPoint(retentionTime + ChromatogramLoadingStatus.TIME_RESOLUTION, 0);
     ModifiedSequence = modifiedSequence;
 }
コード例 #5
0
        public static void zeroTwoSigma1(LineItem originalCurve, PointPair p2, LineItem LineCurve, LineItem curved2, MainProgram form)
        {
            LineItem curve1 = null;
            LineItem curve2 = null;

            form.buttons.Add(GraphProcessing.CreateCurve(ref curve1, form.CurvesDropDownButton, form.ZGCInstance, "Параллель 1", Color.DarkCyan, 2, SymbolType.Default, Color.DarkCyan));
            curve1 = LineCurve;
            form.buttons.Add(GraphProcessing.CreateCurve(ref curve2, form.CurvesDropDownButton, form.ZGCInstance, "Параллель 2", Color.DarkCyan, 2, SymbolType.Default, Color.DarkCyan));
            //int max = 0;
            //for (int i = 0; i < originalCurve.Points.Count; i++) if (originalCurve.Points[i].X > max) max = (int)originalCurve.Points[i].X;
            //double average = 0;
            //for (int i = 0; i < curved2.Points.Count - 10; i++) average += Math.Abs(curved2[i].Y);
            //average /= curved2.Points.Count - 10;
            //int index = 0;
            //for (index = 0; index < curved2.Points.Count; index++) { if (curved2[index].Y > 10.0 * average) break; }
            double offSetY = originalCurve[originalCurve.Points.Count - 4].Y - p2.Y;
            double offSetX = originalCurve[originalCurve.Points.Count - 4].X - p2.X;

            for (int i = 0; i < LineCurve.Points.Count - 1; i++)
            {
                curve1.AddPoint(new PointPair(LineCurve.Points[i].X + offSetX, LineCurve.Points[i].Y += offSetY));
            }
            int offSetX2 = (int)Math.Round(0.98 * originalCurve.Points[originalCurve.Points.Count - 4].X);

            for (int i = 0; i < curve1.Points.Count; i++)
            {
                curve2.AddPoint(new PointPair(curve1.Points[i].X + offSetX2, curve1.Points[i].Y));
            }
        }
コード例 #6
0
        public static PointPair parallelLineSigma(double offSetCoef, MainProgram form, LineItem LineCurve, LineItem originalCurve, double distance, string name)
        {
            double   k1     = form.kCoef;
            double   b1     = (-offSetCoef * distance + form.bCoef);
            LineItem curve3 = new LineItem(name);

            form.buttons.Add(GraphProcessing.CreateCurve(ref curve3, form.CurvesDropDownButton, form.ZGCInstance, name, Color.Purple, 1, SymbolType.Default, Color.Purple));
            for (int i = 0; i < 1.5 * LineCurve[LineCurve.Points.Count - 1].X; i++)
            {
                if ((k1 * i + b1) > 0)
                {
                    curve3.AddPoint(new PointPair(i, k1 * i + b1));
                }
            }
            curve3.Tag = 1;
            bool      intersects = false;
            int       index1     = 1;
            PointPair temp       = null;

            while (index1 < originalCurve.Points.Count - 2 && !intersects)
            {
                PointPair point1 = originalCurve[index1 - 1];
                PointPair point2 = originalCurve[index1];
                temp = lineLineIntersection(point1, point2, k1, b1);
                if (temp.X >= point1.X && temp.X <= point2.X)
                {
                    if (temp.Y >= point1.Y && temp.Y <= point2.Y)
                    {
                        intersects = true;
                    }
                }
                index1++;
            }
            return(temp);
        }
コード例 #7
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            double x = (double)new XDate(DateTime.Now);
            double y = Math.Sin(i * Math.PI / 15.0) * 16.0;

            dataGridView1.Rows[0].Cells[2].Value = y * rd.NextDouble();
            dataGridView1.Rows[0].Cells[3].Value = y;

            if (y < Convert.ToDouble(dataGridView1.Rows[0].Cells[4].Value))
            {
                dataGridView1.Rows[0].Cells[4].Value = y;
            }
            if (y > Convert.ToDouble(dataGridView1.Rows[0].Cells[5].Value))
            {
                dataGridView1.Rows[0].Cells[5].Value = y;
            }
            //if (myCurve.Points.Count > 100)
            //{
            //    myCurve.RemovePoint(0);
            //}
            myCurve.AddPoint(x, y);

            //double x1=0, y1=0;
            myPane.ReverseTransform(new PointF((float)myPane.XAxis.Scale.Min, 0f), out x, out y);
            //XDate xd = new XDate(x1);
            zedGraphControl1.AxisChange();
            zedGraphControl1.Refresh();
            //myPane.GetImage(true).Save(); //调用保存接口
            i++;

            //radTrackBar1.Value = 0.5f * i;
            radTrackBar1.Maximum = i;
            //radTrackBar1.Value = i;
            radTrackBar1.Ranges.Maximum     = i;
            this.radTrackBar1.Ranges[0].End = i;
            try
            {
                //radTrackBar1.Ranges.Maximum = 0.5f * i;
                //radTrackBar1.Ranges.Maximum = 0.5f * i;
                if (i > (xMax - xSpace))
                {
                    this.radTrackBar1.Ranges[0].Start = i - xMax + xSpace;
                }
                else
                {
                    this.radTrackBar1.Ranges[0].Start = 0;
                }
            }
            catch
            { }
            if (iPos < xMax - xSpace)
            {
                iPos++;
            }
            else
            {
                myPane.XAxis.Scale.Min++;
                myPane.XAxis.Scale.Max++;
            }
        }
コード例 #8
0
 private void UpdateZGraph(ZedGraphControl z, string s)
 {
     if (z.InvokeRequired)
     {
         axisChangeZedGraphCallBack dlz = new axisChangeZedGraphCallBack(UpdateZGraph);
         z.Invoke(dlz, new object [] { z, s });
     }
     else
     {
         int a, b, c;
         if (Sending_enable == 1)
         {
             if (s[0] != 'p')
             {
                 a     = s[0] - 48; b = s[1] - 48; c = s[3] - 48;
                 speed = 10 * (double)a + (double)b + 0.1 * (double)c;
                 time  = time + 0.025;
                 myCurveTwo.AddPoint(time, setpoint);
                 myCurveOne.AddPoint(time, speed);
                 z.AxisChange();
                 //z.Invalidate();
                 z.Refresh();
             }
         }
     }
 }
コード例 #9
0
 /// <summary>
 /// Addss a point to a LineItem curve with coordinates x and y, used for the delegate.
 /// </summary>
 /// <param name="curve">Curve to add point to</param>
 /// <param name="x">x point coordinate</param>
 /// <param name="y">y point coordinate</param>
 static internal void AddInRealTime(LineItem curve, double x, double y)
 {
     if (curve != null)
     {
         curve.AddPoint(x, y);
     }
 }
コード例 #10
0
        public void updateChartData(List <List <float> > actual, List <List <float> > predicted)
        {
            actualData.Clear();
            predictedData.Clear();
            //
            for (int i = 0; i < actual.Count; i++)
            {
                float act  = 0;
                float pred = 0;
                //category output
                if (actual[i].Count > 1)
                {
                    act  = actual[i].IndexOf(actual[i].Max());
                    pred = predicted[i].IndexOf(predicted[i].Max());
                }
                else
                {
                    act  = actual[i].First();
                    pred = predicted[i].First();
                }


                actualData.AddPoint(new PointPair(i, act));
                predictedData.AddPoint(new PointPair(i, pred));
            }

            zedModel.RestoreScale(zedModel.GraphPane);
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: BluePandaLi/MobiVU
        void SetAxis(int iIDThread)
        {
            FileStream   f = File.Open(iIDThread.ToString() + ".bin", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            BinaryReader b = new BinaryReader(f);
            int          iVal;

            _myCurve.Clear();
            byte[] byArray = new byte[4];
            int    iFrame  = 0;

            try{
                while (true)
                {
                    iVal = b.ReadInt32();
                    PointPair p = new PointPair(iFrame, iVal);
                    iFrame++;
                    _myCurve.AddPoint(p);
                }
            }
            catch (Exception) { }
            zedGraphControl1.AxisChange();
            zedGraphControl1.Refresh();
            b.Close();
            f.Close();
        }
コード例 #12
0
        public void UpdateChartError(int curIter, double currError, bool isFinished = false)
        {
            if (curIter + 1 < learningErrorLine.Points.Count)
            {
                learningErrorLine.Clear();
            }

            learningErrorLine.AddPoint(curIter, currError);

            eb_currentIteration.Text = curIter.ToString();

            if (curIter % 10 == 0 || isFinished)
            {
                zedFitness.RestoreScale(zedFitness.GraphPane);
            }
        }
コード例 #13
0
        /// <summary>
        /// Proces of updating chart with new data
        /// </summary>
        /// <param name="y"></param>
        /// <param name="isGPData"></param>
        public void UpdateChartDataPoint(double[] y, bool isGPData)
        {
            if (this.zedModel.GraphPane == null)
            {
                return;
            }

            LineItem li = null;

            if (isGPData)
            {
                li = gpModelLine[0];
            }
            else
            {
                li = gpDataLine[0];
            }

            li.Clear();
            for (int i = 0; y != null && i < y.Length; i++)
            {
                li.AddPoint(i + 1, y[i]);
            }

            if (this.zedModel.GraphPane.CurveList.Count == 1)
            {
                this.zedModel.GraphPane.AxisChange(this.CreateGraphics());
            }
            this.zedModel.Refresh();
        }
コード例 #14
0
ファイル: RunPanel.cs プロジェクト: bhrnjica/gpdotnetv4
        /// <summary>
        /// Uodate GP Model chart when data or GP model is changed
        /// </summary>
        /// <param name="y">output value</param>
        /// <param name="gpModel"> indicator is it about GPMOdel or Data Point</param>
        public void UpdateChartDataPoint(double[] y, bool gpModel = true)
        {
            if (this.zedModel.GraphPane == null)
            {
                return;
            }

            LineItem li = null;

            if (gpModel)
            {
                li = gpModelLine;
            }
            else
            {
                li = gpDataLine;
            }

            li.Clear();
            for (int i = 0; i < y.Length; i++)
            {
                li.AddPoint(i + 1, y[i]);
            }


            this.zedModel.GraphPane.AxisChange(this.CreateGraphics());
            this.zedModel.Refresh();
        }
コード例 #15
0
        private void doPlot(object sender, EventArgs e)
        {
            string[] bElements    = bTxt.Text.Split(',');
            string[] aElements    = aTxt.Text.Split(',');
            int      numSamples   = Convert.ToInt32(samplesNumberTextField.Text);
            double   samplingTime = 1.0 / tsBar.Value;
            int      sampleNumber = 0;

            outputCurve.Clear();

            for (double i = 0; i < numSamples; i += samplingTime)
            {
                outputVal = 0;
                for (int ib = 0; ib < bElements.Length; ib++)
                {
                    outputVal += Convert.ToDouble(bElements[ib]) * inSig[(sampleNumber - ib) * samplingTime];
                }
                for (int ia = 0; ia < aElements.Length; ia++)
                {
                    if (sampleNumber - ia - 1 >= 0)
                    {
                        outputVal -= Convert.ToDouble(aElements[ia]) * outputCurve[sampleNumber - ia - 1].Y;
                    }
                }
                outputCurve.AddPoint(i, outputVal);
                sampleNumber++;
            }
            zedGraphControl1.AxisChange();
            zedGraphControl1.Refresh();
        }
コード例 #16
0
        private void AddPainCursorCurves()
        {
            GraphPane pane = optionPainGraph.GraphPane;
            double    x    = core.StockLastPrice;

            // graph marker symbol
            pain_cursor_symb = pane.AddCurve("Cursor", null, Config.Color.GraphCurveForeColor(0), SymbolType.Circle);
            pain_cursor_symb.AddPoint(new PointPair(x, 0));
            pain_cursor_symb.Symbol.Size = 7;
            pain_cursor_symb.Symbol.Fill = new Fill(Config.Color.GraphCurveForeColor(0));
            pain_cursor_symb.Line.Style  = System.Drawing.Drawing2D.DashStyle.Dot;

            pain_cursor_line = pane.AddCurve(string.Empty, null, Config.Color.GraphCurveForeColor(0), SymbolType.None);
            pain_cursor_line.AddPoint(new PointPair(x, pane.YAxis.Scale.Min));
            pain_cursor_line.AddPoint(new PointPair(x, pane.YAxis.Scale.Max));
            pain_cursor_line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
        }
コード例 #17
0
        internal static void SecondDerivativeGraph(LineItem curve, ref LineItem printCurve)
        {
            int length = curve.Points.Count;

            for (int i = 1; i < length - 2; i++)
            {
                printCurve.AddPoint(curve.Points[i + 1].X, (curve.Points[i + 1].Y - curve.Points[i].Y) / (curve.Points[i + 1].X - curve.Points[i].X));
            }
        }
コード例 #18
0
        private void AddVolatilityCursorCurves()
        {
            GraphPane pane = volatilityGraph.GraphPane;

            int i = volatility_x.Length / 2;

            // graph marker symbol
            volatility_cursor_symb = pane.AddCurve("Cursor", null, Config.Color.GraphCurveForeColor(0), SymbolType.Circle);
            volatility_cursor_symb.AddPoint(new PointPair(volatility_x[i], volatility_y[i]));
            volatility_cursor_symb.Symbol.Size = 7;
            volatility_cursor_symb.Symbol.Fill = new Fill(Config.Color.GraphCurveForeColor(0));
            volatility_cursor_symb.Line.Style  = System.Drawing.Drawing2D.DashStyle.Dot;

            volatility_cursor_line = pane.AddCurve(string.Empty, null, Config.Color.GraphCurveForeColor(0), SymbolType.None);
            volatility_cursor_line.AddPoint(new PointPair(volatility_x[i], pane.YAxis.Scale.Min));
            volatility_cursor_line.AddPoint(new PointPair(volatility_x[i], pane.YAxis.Scale.Max));
            volatility_cursor_line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
        }
コード例 #19
0
        private void but_start_Click(object sender, EventArgs e)
        {
            GraphPane myPane = zedGraphControl1.GraphPane;
            var       line   = new LineItem("ScanPoints", new RollingPointPairList(20), Color.White, SymbolType.Diamond);
            var       sonar  = new LineItem("Sonar", new PointPairList(), Color.Red, SymbolType.Circle);

            sonar.AddPoint(0, 0);
            line.Line.IsVisible = false;
            myPane.Title.Text   = "ST-1000 Sonar";
            myPane.CurveList.Add(line);
            myPane.CurveList.Add(sonar);
            myPane.YAxis.Scale.IsReverse     = true;
            myPane.YAxis.Title.Text          = "Depth (m)";
            myPane.YAxis.Title.Text          = "Distance (m)";
            myPane.XAxis.Scale.Max           = 2; myPane.XAxis.Scale.Min = -2;
            myPane.YAxis.Scale.Max           = 5; myPane.YAxis.Scale.Min = 0;
            myPane.XAxis.MajorGrid.Color     = Color.DimGray;
            myPane.YAxis.MajorGrid.Color     = Color.DimGray;
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;


            var subscribeToPacket =
                mav.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.SCANNING_SONAR,
                                          message =>
            {
                MAVLink.mavlink_scanning_sonar_t S = (MAVLink.mavlink_scanning_sonar_t)message.data;
                data_txt = $"{S.time_boot_ms},{S.range / 1000.0},{S.angle / 10.0},{S.roll / 10.0},{S.pitch / 10.0},{S.yaw / 10.0}";

                data_txt += Environment.NewLine;


                double deg2rad = Math.PI / 180;
                double Y       = S.range / 1000.0 * Math.Cos((double)(S.angle / 10.0) * deg2rad);
                double X       = S.range / 1000.0 * Math.Sin((double)(S.angle / 10.0) * deg2rad);
                line.AddPoint(X, Y);

                double Total = 0;
                for (int I = 0; I < line.NPts; I++)
                {
                    Total += line.Points[I].Y;
                }
                double AvgY = Total / line.NPts;
                try
                {
                    textBox1.Invoke(new Action(() => textBox1.AppendText(data_txt)));
                    textBoxDepth.Invoke(new Action(() => textBoxDepth.Text = AvgY.ToString("F1")));
                    textBoxRoll.Invoke(new Action(() => textBoxRoll.Text   = (S.roll / 10.0).ToString("F1")));
                }
                catch (ObjectDisposedException) { }
                //zedGraphControl1.AxisChange();
                zedGraphControl1.Invalidate();
                return(true);
            });
            // timer.Enabled = true;
        }
コード例 #20
0
 public static void leastSquaresBuild(ref LineItem curve, double k, double b, int end)
 {
     for (int i = 0; i < end; i++)
     {
         if (k * i + b > 0)
         {
             curve.AddPoint(new PointPair(i, k * i + b));
         }
     }
 }
コード例 #21
0
        internal static void DerivativeGraph(LineItem curve, ref LineItem printCurve)
        {
            int length = curve.Points.Count;

            for (int i = 1; i < length - 2; i++)
            {
                double bottom = 2 * (curve.Points[i + 1].X - curve.Points[i].X);
                double top    = (curve.Points[i + 1].Y - curve.Points[i - 1].Y);
                printCurve.AddPoint(curve.Points[i + 1].X, top / bottom);
            }
        }
コード例 #22
0
        private void AddHistoryCursorCurves()
        {
            GraphPane pane = historyGraph.GraphPane;

            int i = history_x.Length / 2;

            // graph marker symbol
            history_cursor_symb = pane.AddCurve("Cursor", null, Config.Color.GraphMarkerForeColor, SymbolType.Circle);
            history_cursor_symb.AddPoint(new PointPair((double)i, history_y[i]));
            history_cursor_symb.Symbol.Size       = 8;
            history_cursor_symb.Symbol.Fill       = new Fill(Config.Color.GraphMarkerForeColor);
            history_cursor_symb.Line.Style        = System.Drawing.Drawing2D.DashStyle.Dot;
            history_cursor_symb.IsOverrideOrdinal = true;

            history_cursor_line = pane.AddCurve(string.Empty, null, Config.Color.GraphMarkerForeColor, SymbolType.None);
            history_cursor_line.AddPoint(new PointPair((double)i, pane.YAxis.Scale.Min));
            history_cursor_line.AddPoint(new PointPair((double)i, pane.YAxis.Scale.Max));
            history_cursor_line.Line.Style        = System.Drawing.Drawing2D.DashStyle.Dot;
            history_cursor_line.IsOverrideOrdinal = true;
        }
コード例 #23
0
        private void updateChartFitness(int i, float loss, float eval, bool refresh = true)
        {
            //

            lossFunction.AddPoint(new PointPair(i, loss));
            evalFunciton.AddPoint(new PointPair(i, eval));

            if (refresh)
            {
                zedFitness.RestoreScale(zedFitness.GraphPane);
            }
        }
コード例 #24
0
        private void refreshGP()
        {
            LineItem li = this.zedGraphControl1.GraphPane.CurveList[0] as LineItem;

            li.Clear();
            for (int i = 0; i < TemperatureLine.TemperaturePointNumber; i++)
            {
                li.AddPoint(Convert.ToInt32(this.dataGrid1[i, 1]),
                            Convert.ToInt32(this.dataGrid1 [i, 2]));
            }
            this.zedGraphControl1.Invalidate();
        }
コード例 #25
0
        /// <summary>
        /// Build a curve using the least squares method
        /// </summary>
        /// <param name="begin"></param>
        /// <param name="end"></param>
        /// <param name="xData"></param>
        /// <param name="yData"></param>
        /// <param name="curve"></param>
        /// <param name="form"></param>
        public static double[] leastSquaresBuild(int begin, int end, LineItem allPointsForBuilding, ref LineItem curve, MainProgram form)
        {
            double[] data = LeastSquareData(allPointsForBuilding);
            double   k    = data[0];
            double   b    = data[1];

            curve.Tag = 2;
            for (int i = begin; i < end; i++)
            {
                curve.AddPoint(new PointPair(i, k * i + b));
            }
            return(new double[] { k, b });
        }
コード例 #26
0
ファイル: BaseRunPanel.cs プロジェクト: bhrnjica/gpdotnetv4
        /// <summary>
        /// Update current fitness simulation
        /// </summary>
        /// <param name="currEvolution">current evolution of GP Model </param>
        /// <param name="max">maximum fitness value of the current evolution</param>
        /// <param name="avg">average fitness value of the current evolution</param>
        public void UpdateChartFitness(int currEvolution, double max, double avg, bool isFinished = false)
        {
            if (currEvolution + 1 < gpMaxFitnLine.Points.Count)
            {
                gpMaxFitnLine.Clear();
            }

            if (currEvolution + 1 < gpAvgFitnLine.Points.Count)
            {
                gpAvgFitnLine.Clear();
            }

            if (gpMaxFitnLine.Points.Count <= currEvolution)
            {
                gpMaxFitnLine.AddPoint(currEvolution, max);
                gpAvgFitnLine.AddPoint(currEvolution, avg);
            }
            if (currEvolution % 10 == 0 || isFinished)
            {
                zedFitness.RestoreScale(zedFitness.GraphPane);
            }
        }
コード例 #27
0
        private void timerLeitura_Tick(object sender, EventArgs e)
        {
            if (minhaporta.BytesToRead > 5)
            {
                string linha_lida = minhaporta.ReadLine();
                double valor_lido = Convert.ToDouble(linha_lida);
                if (metroTabControl1.SelectedTab == metroTabPagePortaSerial)
                {
                    //Console.WriteLine("Updating text");
                    metroTextBoxValoresLidos.Text = linha_lida + "\n" + metroTextBoxValoresLidos.Text;
                }
                else if (metroTabControl1.SelectedTab == metroTabPageGrafico)
                {
                    if (metroToggleGrafico.Checked)
                    {
                        //Console.WriteLine("Updating chart");
                        emgLine.AddPoint(valor_x, valor_lido);
                        valor_x += 50.0 / 1000.0;           //50 ms

                        if (emgLine.Points.Count > 20 * 30) //20Hz * 30s
                        {
                            emgLine.Points.RemoveAt(0);
                        }

                        zg1.AxisChange();
                        zg1.Invalidate();
                    }
                }
                else if (metroTabControl1.SelectedTab == metroTabPageMusica)
                {
                    if (metroToggleMusica.Checked)
                    {
                        metroProgressSpinnerSom.Value = (int)(valor_lido * 100);
                        metroLabel42.Text             = valor_lido.ToString() + " V";
                        //Se antes era menor e agora é maior
                        if (valor_anterior <= valor_limiar && valor_lido > valor_limiar)
                        {
                            contracao_comecou();
                        }
                        else if (valor_anterior > valor_limiar && valor_lido <= valor_limiar) //Se antes era maior e agora é menor
                        {
                            contracao_terminou();
                        }
                    }
                }
                if (valor_lido != valor_anterior)
                {
                    valor_anterior = valor_lido;
                }
            }
        }
コード例 #28
0
        public static void zeroTwoSigma2(LineItem originalCurve, PointPair p2, LineItem LineCurve, LineItem curved2, MainProgram form)
        {
            LineItem curve1 = null;
            LineItem curve2 = null;

            form.buttons.Add(GraphProcessing.CreateCurve(ref curve1, form.CurvesDropDownButton, form.ZGCInstance, "Паралелль 1", Color.DarkCyan, 4, SymbolType.Default, Color.DarkCyan));
            form.buttons.Add(GraphProcessing.CreateCurve(ref curve2, form.CurvesDropDownButton, form.ZGCInstance, "Паралелль 2", Color.DarkCyan, 4, SymbolType.Default, Color.DarkCyan));

            int max = 0;

            for (int i = 0; i < originalCurve.Points.Count; i++)
            {
                if (originalCurve.Points[i].X > max)
                {
                    max = (int)originalCurve.Points[i].X;
                }
            }
            double average = 0;

            for (int i = 0; i < curved2.Points.Count - 10; i++)
            {
                average += Math.Abs(curved2[i].Y);
            }
            average /= curved2.Points.Count - 10;
            int index = 0;

            for (index = 0; index < curved2.Points.Count; index++)
            {
                if (curved2[index].Y > 10.0 * average)
                {
                    break;
                }
            }
            double offSetY = originalCurve[index].Y - p2.Y;
            double offSetX = originalCurve[index].X - p2.X;

            for (int i = 0; i < LineCurve.Points.Count - 1; i++)
            {
                double x = LineCurve.Points[i].X - offSetX;
                double y = LineCurve.Points[i].Y + offSetY;
                curve1.AddPoint(new PointPair(x, y));
            }
            int offSetX2 = (int)Math.Round(0.8 * curve1.Points[0].X);

            for (int i = 0; i < curve1.Points.Count; i++)
            {
                curve2.AddPoint(new PointPair(curve1.Points[i].X - offSetX2, curve1.Points[i].Y));
            }
            curve1.Tag = 5;
            curve2.Tag = 5;
        }
コード例 #29
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (plot == true)
     {
         xAxis += 0.1;
         myCurve.AddPoint(xAxis, yAxis);
         zedGraphControl1.AxisChange();
         zedGraphControl1.Refresh();
     }
     else
     {
         VoltageMeterLabel.Text = yAxis.ToString();
     }
 }
コード例 #30
0
        private void btnSweep_Click(object sender, EventArgs e)
        {
            var save = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            try
            {
                //  CurveReal.Clear();
                //  CurveImaginary.Clear();
                //  CurvePhase.Clear();
                CurveMagnitude.Clear();
                CurveCole.Clear();

                foreach (var snap in eval.SweepMeasure())
                {
                    //    CurveReal.AddPoint(snap.Frequency, snap.RealPart);
                    //   CurveImaginary.AddPoint(snap.Frequency, snap.ImaginaryPart);
                    //   CurvePhase.AddPoint(snap.Frequency, snap.Phase);
                    CurveMagnitude.AddPoint(snap.Frequency, snap.Impedance);

                    CurveCole.AddPoint(snap.RealPart, snap.ImaginaryPart);



                    mainGraph.AxisChange();
                    mainGraph.Invalidate();
                }
                colePlot.AxisChange();
                colePlot.Invalidate();
            }
            finally
            {
                this.Cursor = save;
            }



/*            if (eval != null)
 *         {
 *              eval.DoSweep().Subscribe((snap) =>
 *              {
 *                  zedGraphControl1.
 *              });
 *          } */
        }