private void BtnSelectProduct_Click(object sender, RoutedEventArgs e)
        {
            float totalSalesCounter = 0;
            var   selectedCustomer  = (Customer)customerComboBox.SelectedItem;
            var   moment            = DateTime.Now;

            totalSales.Clear();
            totalSalesLastYear.Clear();
            for (var i = 1; i <= 12; i++)
            {
                totalSales.Add(CustomerViewModel.getTotalSalesMonthYear(selectedCustomer.idCustomer, i, moment.Year));
                totalSalesCounter += CustomerViewModel.getTotalSalesMonthYear(selectedCustomer.idCustomer, i, moment.Year);
                totalSalesLastYear.Add(
                    CustomerViewModel.getTotalSalesMonthYear(selectedCustomer.idCustomer, i, moment.Year - 1));
            }
            SeriesCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title  = "Total Sales",
                    Values = totalSales
                },
                new LineSeries
                {
                    Title  = "Last Year Sales",
                    Values = totalSalesLastYear
                }
            };
            salesCount.Text = totalSalesCounter.ToString();
            YFormatter      = value => value.ToString("C");
            DataContext     = this;
        }
Пример #2
0
        protected void ClearCurves(ushort procState, ChartValues <double> valuesBefore, ChartValues <double> valuesAfter, ChartValues <MeasureModel> chartValuesBefore, ChartValues <MeasureModel> chartValuesAfter)
        {
            switch (procState)
            {
            //case 1:
            case 3:
            case 4:
                valuesAfter.Clear();
                chartValuesAfter.Clear();
                break;

            case 9:
            case 10:
                break;

            case 8:
                valuesBefore.Clear();
                chartValuesBefore.Clear();
                break;

            default:
                valuesAfter.Clear();
                valuesBefore.Clear();
                chartValuesAfter.Clear();
                chartValuesBefore.Clear();
                break;
            }
        }
 private void BtStartSimulator_Click(object sender, RoutedEventArgs e)
 {
     if (!DateImputsIsValid())
     {
         MessageBox.Show("Endzeit muss später als Startzeit sein!", "Error", MessageBoxButton.OKCancel);
     }
     else
     {
         RoundedMeasurementsCollection.Clear();
         MeasurementsCollection.Clear();
         MyChartValues.Clear();
         Measurements generatedMeasurement = GenerateMeasurements();
         MeasurementsCollection.Add(generatedMeasurement);
         AddChartValue(generatedMeasurement);
         AddMeasurementToRoundedMeasurementCollection(generatedMeasurement);
         dgMeasurements.ItemsSource = RoundedMeasurementsCollection;
         double generateSpeed = 1.0;
         if ((bool)rbSpeed1.IsChecked)
         {
             generateSpeed = 0.5;
         }
         else if ((bool)rbSpeed3.IsChecked)
         {
             generateSpeed = 10.0;
         }
         dt.Interval = TimeSpan.FromSeconds((double)dudFrequency.Value / generateSpeed);
         dt.Start();
         btStartSimulator.IsEnabled = false;
         btStopSimulator.IsEnabled  = true;
         btSendData.IsEnabled       = false;
         UITimeInput(false);
         UIRightColumnEnabled(false);
     }
 }
Пример #4
0
 public void Clear()
 {
     _player = null;
     _values.Clear();
     _dates    = new List <string>(0);
     _position = 0;
     Update();
 }
Пример #5
0
 public void Reset()
 {
     totalDamageTakenValues.Clear(); totalDamageTakenValues.Add(new ObservablePoint(0, 0));
     totalDPSValues.Clear(); totalDPSValues.Add(new ObservablePoint(0, 0));
     totalDamageTakenValues.Clear(); totalDamageTakenValues.Add(new ObservablePoint(0, 0));
     updateDPSValues.Clear(); updateDPSValues.Add(new ObservablePoint(0, 0));
     averageMPAValues.Clear(); averageMPAValues.Add(new ObservablePoint(0, 0));
     DamageTakenScale = 1;
 }
Пример #6
0
        private void ConnectButton_Click(object sender, EventArgs e)
        {
            if (!m_Connected)
            {
                try
                {
                    m_SerialPort = new SerialPort(ComString, 38400, Parity.None, 8, StopBits.One);
                    m_SerialPort.Open();
                    m_Connected = true;
                }
                catch (Exception exc)
                {
                    System.Windows.Forms.MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                ConnectButton.Text     = "Disconnect";
                SettingsButton.Enabled = false;

                // Flush
                m_SerialPort.ReadExisting();

                Task.Run(() =>
                {
                    ReadTemperaturesTask();
                });
            }
            else
            {
                m_Connected = false;
                m_SerialPort.Close();
                ConnectButton.Text = "Connect";

                StartButton.Enabled    = false;
                FcStartButton.Enabled  = false;
                FcEndButton.Enabled    = false;
                ScEndButton.Enabled    = false;
                ScStartButton.Enabled  = false;
                EndButton.Enabled      = false;
                EventButton.Enabled    = false;
                SettingsButton.Enabled = true;

                m_TemperatureValues.Clear();
                m_AvgTemperatureValues.Clear();
                m_RateOfRiseValues.Clear();
                m_RoastStopwatch.Stop();
                m_MovingAvgHistory.Clear();

                TempLabel.Text    = "000.00°C";
                AvgTempLabel.Text = "000.00°C";
                TimeLabel.Text    = "00:00:000";
                RorLabel.Text     = "00.0°C/min";

                m_Started = false;
            }
        }
Пример #7
0
        private void GetDataForArhiveGraph(List <MeasurementData> arhiveList)
        {
            ChartValuesPOWER_arhive.Clear();
            ChartValuesWEIGHT_arhive.Clear();
            lableX_arhive.Clear();
            if (chechko >= arhiveList.Count)
            {
                chechko = arhiveList.Count;
                next    = chechko - 15;
            }
            if (next < 0)
            {
                chechko = 15;
                next    = 0;
            }

            for (int i = next; i < chechko; i++)
            {
                if (i >= arhiveList.Count)
                {
                    ChartValuesWEIGHT_arhive.Add(0);
                    ChartValuesPOWER_arhive.Add(0);
                    lableX_arhive.Add("");
                }
                else
                {
                    ChartValuesWEIGHT_arhive.Add(arhiveList[i].CurrentWeight.Value);
                    ChartValuesPOWER_arhive.Add(arhiveList[i].CurrentProductivity.Value);
                    lableX_arhive.Add(arhiveList[i].TimeOfMeasurement.Value.ToString("HH:mm:ss") + "\n" + arhiveList[i].TimeOfMeasurement.Value.ToString("dd.MM.yy"));
                }
            }
            cartesianChart1.AxisX[0].Labels = lableX_arhive;
            cartesianChart1.Series          = new SeriesCollection
            {
                new LineSeries
                {
                    Values            = ChartValuesWEIGHT_arhive,
                    PointGeometrySize = 18,
                    LineSmoothness    = 0,
                    Title             = "Вес:"
                }
            };
            cartesianChart2.AxisX[0].Labels = lableX_arhive;
            cartesianChart2.Series          = new SeriesCollection
            {
                new LineSeries
                {
                    Values            = ChartValuesPOWER_arhive,
                    PointGeometrySize = 18,
                    LineSmoothness    = 0,
                    Title             = "Производительность:"
                }
            };
        }
Пример #8
0
        private void BindSignal()
        {
            ChartValues.Clear();

            foreach (var item in Signal)
            {
                ChartValues.Add(new ObservableValue(item));
            }
            ChartValues.Add(new ObservableValue(0));
            ChartValues.Add(new ObservableValue(0));
            ChartValues.Add(new ObservableValue(0));
        }
Пример #9
0
        private void UpdateGameScoreDataSource()
        {
            var actualScores = _scores
                               .Select(s => s.ActualScore);

            actualDragonPercentageLabel.Text = CalculateScorePercentageString(_dragonText, actualScores);
            actualTigerPercentageLabel.Text  = CalculateScorePercentageString(_tigerText, actualScores);

            var betScores = _scores
                            .Select(s => s.BetScore);

            betDragonPercentageLabel.Text = CalculateScorePercentageString(_dragonText, betScores);
            betTigerPercentageLabel.Text  = CalculateScorePercentageString(_tigerText, betScores);

            var betResults  = _scores;
            var gameResults = betResults.Select((r, i) =>
            {
                if (string.IsNullOrEmpty(_scores[i].BetScore))
                {
                    return(r.WinRate);
                }

                var betResults1 = betResults.Take(i + 1).Where(r1 => !string.IsNullOrEmpty(r1.BetScore))
                                  .Select(r1 =>
                {
                    r1.Result = r1.ActualScore == r1.BetScore ? _winText : _loseText;
                    return(r1);
                });
                return(r.WinRate = (int)(betResults1.Where(r1 => r1.Result == _winText).Count() / (float)betResults1.Count() * 100));
            }).ToList();

            _chartValues.Clear();
            _chartValues.AddRange(gameResults.Select(r => r ?? double.NaN));
        }
        public void makeGraphic()
        {
            List <Data> datos;

            datos = graphics[slider];
            Data d = datos[0];

            valuesOne.Clear();
            String[] f = datos[0].fecha.Split('/');
            String   y = f[2].Split(' ')[0];
            int      i = 0;

            foreach (Data item in datos)
            {
                String[] fecha = item.fecha.Split('/');
                String   year  = fecha[2].Split(' ')[0];
                labelYear.Text = year;
                if (y.Equals(year))
                {
                    String value = fecha[1] + "" + fecha[0];
                    int    x     = int.Parse(value);
                    valuesOne.Add(new ObservablePoint(i, item.concentracion));
                    i++;
                }
            }
        }
Пример #11
0
        public void SetValues(ChartData chartData, string state)
        {
            this.InitializeComponent();
            _values = new ChartValues <GanttPoint>();
            _values.Clear();
            var labels = new List <string>();

            foreach (Activity activity in chartData.GetActivities())
            {
                if (activity.State == state || state == "all")
                {
                    _values.Add(new GanttPoint(activity.StartDate.Ticks, activity.EndDate.Ticks));
                    labels.Add(activity.Name);
                }
            }

            Series = new SeriesCollection
            {
                new RowSeries
                {
                    Values     = _values,
                    DataLabels = true,
                }
            };


            ResetZoomOnClick(null, null);
            Formatter   = value => new DateTime((long)value).ToString("dd/MM HH:mm");
            Labels      = labels.ToArray();
            DataContext = new SeriesViewModel();
            DataContext = this;
        }
Пример #12
0
 private void modeButton_Click(object sender, RoutedEventArgs e)
 {
     Array.Clear(Labels, 0, Labels.Length);
     if (yearlyMode)
     {
         modeButton.Content = "Váltás éves nézetre";
         topChart.AxisX.Clear();
         topChart.AxisX.Add(new Axis
         {
             Labels = my_labels
         });
     }
     else
     {
         modeButton.Content = "Váltás havi nézetre";
         topChart.AxisX.Clear();
         topChart.AxisX.Add(new Axis
         {
             Labels = generateLabels(earliestYear).ToArray()
         });
     }
     yearlyMode = !yearlyMode;
     cvIncome.Clear();
     cvSpending.Clear();
     createLineChart();
     createStackedAreaChart();
 }
Пример #13
0
 private void Downloader_DownloadCompleted(object sender, DownloadCompletedArg e)
 {
     this.Dispatcher.Invoke(new Action(async() =>
     {
         speedTextBlock.Text       = "0Kb/s";
         progressBar.Maximum       = 1;
         progressBar.Value         = 0;
         progressPerTextBlock.Text = "000%";
         speedValues.Clear();
         for (int i = 0; i < 49; i++)
         {
             speedValues.Add(0);
         }
         if (e.ErrorList == null || e.ErrorList.Count == 0)
         {
             await this.ShowMessageAsync(App.GetResourceString("String.Downloadwindow.DownloadComplete"),
                                         App.GetResourceString("String.Downloadwindow.DownloadComplete2"));
             this.Close();
         }
         else
         {
             await this.ShowMessageAsync(App.GetResourceString("String.Downloadwindow.DownloadCompleteWithError"),
                                         string.Format(App.GetResourceString("String.Downloadwindow.DownloadCompleteWithError2"), e.ErrorList.Count, e.ErrorList.First().Value.Message));
         }
     }));
 }
Пример #14
0
        //
        // Abstract:
        //      Update managerVM's attributs.
        //
        // Parameters:
        //  theDate:
        //      DateTime where the modeling should be ran.
        //
        //  estWindow:
        //      String containing the period where the model should be ran.
        //
        //  frequency:
        //      String containing the step where portefolio is reshuffled.
        public void PleaseUpdateManager(DateTime theDate, string estmWindow, string frequency, IDataFeedProvider simulator, FinancialComputation opt)
        {
            StartDate       = theDate;
            SampleNumber    = Int32.Parse(estmWindow);
            Step            = Int32.Parse(frequency);
            marketSimulator = simulator;
            option          = opt;
            option.MarketDataDates.Clear();
            var window = 20;
            var res    = option.GenChartData(window, StartDate, Step, marketSimulator);

            ValPayOff    = option.PayOff;
            ValPortfolio = res.PortfolioValue.Last().Value;

            Labels = GetDateSet(option.MarketDataDates);
            optp.Clear();
            pfp.Clear();
            trackingError.Clear();
            for (int i = 0; i < res.OptionPrice.Count; i++)
            {
                optp.Insert(i, res.OptionPrice[i]);
                pfp.Insert(i, res.PortfolioValue[i].Value);
                trackingError.Insert(i, res.OptionPrice[i] - res.PortfolioValue[i].Value);
            }
        }
Пример #15
0
        protected void GetGrafPoints()
        {
            if ((grafValueY != null) && (grafValueY != ""))
            {
                if (!run)
                {
                    dataTable.Clear();
                    ChartValues.Clear();
                    grafValueX = "0";
                    grafValueY = "0";

                    run = true;
                }
                DataRow dr = dataTable.NewRow();
                dr[0] = grafValueX;
                dr[1] = grafValueY;
                dataTable.Rows.Add(dr);

                ChartValues.Add(new MeasureModel
                {
                    ValueX = Convert.ToDouble(grafValueX),
                    ValueY = Convert.ToDouble(grafValueY)
                });
                Labels = seriesCollectionHandler.SetValues(SeriesCollection[0].Values, dataTable, 0, 1);
            }
            else
            {
                run = false;
            }
        }
Пример #16
0
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            ClearAgents();
            data.Clear();
            consumers.Clear();
            potential.Clear();
            con = 0;
            agents_has_product.Clear();



            try
            {
                iteration_count  = Int32.Parse(Iteration.Text);
                population_count = Int32.Parse(Pop_count.Text);
                night            = Int32.Parse(Night.Text);
                buy_prob         = Double.Parse(Buy_prob.Text.Replace('.', ','));
                notify_prob      = Double.Parse(Notify_prob.Text.Replace('.', ','));
                spoil_time       = Byte.Parse(Spoiling.Text);
                Recalculation();
                pot = (int)population_count;
                Draw();
                ScaleChange.IsEnabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            Task.Run(() =>
            {
                var r = new Random();

                for (int i = 0; i < iteration_count; i++)
                {
                    Thread.Sleep(night);


                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        int buy_today = Buying();
                        Notificate(buy_today);
                        int returned = Spoil();
                        pot          = pot - buy_today + returned;
                        con          = con + buy_today - returned;
                        consumers.Add(con);
                        potential.Add(pot);
                        data.Add(new Data()
                        {
                            Day = i + 1, Consumer = con, Potential = pot
                        });
                    });
                }
                Application.Current.Dispatcher.Invoke(() =>
                {
                    ScaleChange.IsEnabled = true;
                });
            });
        }
Пример #17
0
 public void DrawChart(ref ToolStripMenuItem btn, IEnumerable <double> dataSet)
 {
     chartValues.Clear();
     if (btn.Checked && dataSet.Count() != 0)
     {
         chartValues.AddRange(dataSet.Reverse().Take(360).Reverse());
     }
 }
        private void BtnSelectProduct_Click(object sender, RoutedEventArgs e)
        {
            int   totalUnitSales    = 0;
            float totalProductSales = 0;

            Labels = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

            var selectedProduct = (Product)productComboBox.SelectedItem;
            var moment          = DateTime.Now;

            total.Clear();
            totalSales.Clear();
            totalLastYear.Clear();
            totalSalesLastYear.Clear();

            for (var i = 1; i <= 12; i++)
            {
                total.Add(ProductViewModel.getProductCount(selectedProduct.idProduct, i, moment.Year));
                totalSales.Add(ProductViewModel.getProductSales(selectedProduct.idProduct, i, moment.Year));
                totalLastYear.Add(ProductViewModel.getProductCount(selectedProduct.idProduct, i, moment.Year - 1));
                totalSalesLastYear.Add(ProductViewModel.getProductSales(selectedProduct.idProduct, i, moment.Year - 1));
                totalUnitSales    += ProductViewModel.getProductCount(selectedProduct.idProduct, i, moment.Year);
                totalProductSales += ProductViewModel.getProductSales(selectedProduct.idProduct, i, moment.Year);
            }
            SeriesCollection = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Total Sales",
                    Values = totalSales
                },
                new ColumnSeries
                {
                    Title  = "Last Year Sales",
                    Values = totalSalesLastYear
                }
            };
            SeriesCollection2 = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Total Products",
                    Values = total
                },
                new ColumnSeries
                {
                    Title  = "Last Year Total Products",
                    Values = totalLastYear
                }
            };
            YFormatter             = value => value.ToString("C");
            YFormatter2            = value => value.ToString();
            salesCount.Text        = totalProductSales.ToString();
            productSalesCount.Text = totalUnitSales.ToString();

            DataContext = this;
        }
Пример #19
0
        public static void FillMonthChart(ChartValues <double> chart, List <Category> categories)
        {
            chart.Clear();

            foreach (Category category in categories)
            {
                chart.Add(double.Parse(category.Cost));
            }
        }
Пример #20
0
        private void Read3()
        {
            // double x = 1528.5;
            // double y = 6.55733501913825e-46;
            float x;
            float y;
            List <(ushort x, ushort y)> ulist  = new List <(ushort x, ushort y)>();
            List <(float x, float y)>   fllist = new List <(float x, float y)>();
            var list = ChartValues.ToList();

            while (IsReading)
            {
                Thread.Sleep(500);
                ushort[] b = ModbusCommand.command.Operation(Getter.channel_spectral_ch1);
                ulist.Add((b[0], b[1]));
                x = ((float)b[0]) / 1000 + 1520;
                y = Utility.GetSingle(0, b[1]);

                fllist.Add((x, y));
                MeasureModel m = new MeasureModel
                {
                    ValueX = (double)x,
                    ValueY = (double)y
                };
                list.Add(m);
                try
                {
                    list = list.OrderBy(t => t.ValueX).ToList();
                    ChartValues.Clear();
                    ChartValues.AddRange(list);
                }
                catch (Exception e)
                {
                    var t = e;
                }
                //   ChartValues = v1;
                //ChartValues.Add(new MeasureModel
                //{
                //    ValueX = x,
                //    ValueY = y

                //    //     DateTime = now,
                //    //    Value = _trend
                //});
                // SetAxisLimits(now);
                //  if (ChartValues.Count > 100) ChartValues.RemoveAt(0);
            }


            //var x1 = fllist.Select(b => b.x);
            //var y1 = fllist.Select(b => b.y);
            //float maxx = x1.Max();
            //float minx = x1.Min();
            //float maxy = y1.Max();
            //float miny = y1.Min();
        }
Пример #21
0
        //Adds optimization values to array that updates graph display
        public void AppendStoredValues()
        {
            this.RadicalVM.ObjectiveEvolution.AddRange(StoredMainValues);
            StoredMainValues.Clear();

            for (int i = 0; i < this.RadicalVM.ConstraintsEvolution.Count; i++)
            {
                this.RadicalVM.ConstraintsEvolution[i].AddRange(StoredConstraintValues[i]);
                StoredConstraintValues[i].Clear();
            }
        }
Пример #22
0
        private async void DisconectButton_Click(object sender, RoutedEventArgs e)
        {
            if (timer.IsEnabled)
            {
                timer.Stop();
            }
            CancelAllIoTasks();
            ValuesFromRead.Clear();
            await WriteReadTaskAsync("s");

            Disconect();
        }
        public ShellViewModel()
        {
            DisplayName = "Arduino Monitoring App";

            Ports  = new BindableCollection <string>();
            Values = new ChartValues <double> {
                0
            };

            Values.Clear();
            InitControls();
        }
Пример #24
0
 private void UpdateChart()
 {
     UpdateQueueValue();
     this.chart1.Series[0].Points.Clear();
     Values.Clear();
     for (int i = 0; i < dataQueue.Count; i++)
     {
         this.chart1.Series[0].Points.AddXY((i + 1), dataQueue.ElementAt(i));
         Values.Add(dataQueue.ElementAt(i));
     }
     myLineSeries.Values = Values;
 }
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     lableX.Clear();
     if (clearData == true)
     {
         ChartValues.Clear();
         ChartValuesWEIGHT.Clear();
     }
     //chart3DataX.Clear();
     //chart3DataY.Clear();
     CURRENT_DEVICE_COMBO = comboBox1.SelectedItem.ToString().Split(' ')[0];
 }
Пример #26
0
        //aggiunge una serie per il chart di movimento dei MAC
        public void AddSeries(string mac)
        {
            scatter.Clear();

            foreach (DatiDispositivo ph in macList)
            {
                if (ph.MAC_Address == mac)
                {
                    scatter.Add(ph);
                    if (ph.Posizione.Ascissa < minX)
                    {
                        minX = ph.Posizione.Ascissa;
                    }
                    if (ph.Posizione.Ascissa > maxX)
                    {
                        maxX = ph.Posizione.Ascissa;
                    }
                    if (ph.Posizione.Ordinata < minY)
                    {
                        minY = ph.Posizione.Ordinata;
                    }
                    if (ph.Posizione.Ordinata > maxY)
                    {
                        maxY = ph.Posizione.Ordinata;
                    }
                }
            }
            _movement.Series.Add(new LineSeries()
            {
                Title             = Utilities.Utils.Formatta_MAC_Address(mac),
                PointGeometry     = DefaultGeometries.Diamond,
                PointGeometrySize = 10,
                StrokeThickness   = 4,
                Fill = Brushes.Transparent,
            });

            if (!macToIndex.ContainsKey(mac))
            {
                macToIndex.Add(mac, _movement.Series.Count - 1); //associa un indice ad un determinato mac per poi recuperare la serie corrispondente
            }
            _movement.Series[macToIndex[mac]].LabelPoint = point => string.Format("Timestamp:{0} \n X:{1}  Y:{2}",
                                                                                  new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(((DatiDispositivo)point.Instance).Timestamp),
                                                                                  ((DatiDispositivo)point.Instance).Posizione.Ascissa, ((DatiDispositivo)point.Instance).Posizione.Ordinata);

            _movement.Series[macToIndex[mac]].Configuration = Mappers.Xy <DatiDispositivo>().X(b => b.Posizione.Ascissa).Y(b => b.Posizione.Ordinata);
            _movement.Series[macToIndex[mac]].Values        = new ChartValues <DatiDispositivo>(scatter);
            _movement.AxisX[0].MinValue = minX - 5;
            _movement.AxisX[0].MaxValue = maxX + 5;
            _movement.AxisY[0].MinValue = minY - 5;
            _movement.AxisY[0].MaxValue = maxY + 5;
        }
Пример #27
0
        public static Tuple <double, double> GradientDescent(double[,] data, double thetaOne, double thetaTwo, ChartValues <ObservablePoint> hypothesis, double interations)
        {
            Debug.OutPut("--- INITIAL ---" + thetaOne + " " + thetaTwo);
            double m = data.GetLength(0);

            int count = 0;

            while (count < interations)
            {
                double sumOne = 0;
                double sumTwo = 0;
                for (int i = 0; i < m; i++)
                {
                    Point  currentPoint = new Point(data[i, 0], data[i, 1]);
                    double modelValue   = SolveRegressionModel(currentPoint.X, thetaOne, thetaTwo);
                    sumOne += modelValue - currentPoint.Y;
                }
                double tempThetaOne = thetaOne - LeariningRate * (1 / m) * sumOne;

                for (int i = 0; i < m; i++)
                {
                    Point  currentPoint = new Point(data[i, 0], data[i, 1]);
                    double modelValue   = SolveRegressionModel(currentPoint.X, thetaOne, thetaTwo);
                    sumTwo += (modelValue - currentPoint.Y) * currentPoint.X;
                }
                double tempThetaTwo = thetaTwo - LeariningRate * (1 / m) * sumTwo;

                thetaOne = tempThetaOne;
                thetaTwo = tempThetaTwo;
                Debug.OutPut("Iter: " + count + " T0: " + thetaOne + " T1: " + thetaTwo);
                count++;

                if (count % 10 == 0)
                {
                    // Add for first
                    var x = 0;
                    var y = thetaOne + thetaTwo * x;
                    var a = new ObservablePoint(x, y);

                    x = 20;
                    y = thetaOne + thetaTwo * x;
                    var b = new ObservablePoint(x, y);

                    hypothesis.Clear();
                    hypothesis.Add(a);
                    hypothesis.Add(b);
                }
            }

            return(new Tuple <double, double>(thetaOne, thetaTwo));
        }
Пример #28
0
        /// <summary>
        /// Clears datum showed at the program (e.g. charts).
        /// </summary>
        private void ClearData()
        {
            runTreeView.Nodes.Clear();
            speciesTabFitnessChart.Series.Clear();
            generationGenomeSizeChart.Series.Clear();
            generationFitnessChart.Series.Clear();
            generationGenomePerSpeciesChart.Series.Clear();

            runAvgFitnessValues.Clear();
            runMaxFitnessValues.Clear();
            runBestGenomeSizeValues.Clear();

            runAvgGenomeSizeValues.Clear();
            runMaxGenomeSizeValues.Clear();
        }
 private void Chart(int k)
 {
     Values1.Clear();
     for (int i = 0; i < ValutesCurs.Count - 1; i++)
     {
         Values1.Add
         (
             new DateModel
         {
             Value    = Convert.ToDouble(ValutesCurs[i].Valutes[k].Value),
             DateTime = Convert.ToDateTime(ValutesCurs[i].StringDate)
         }
         );;
     }
 }
Пример #30
0
        protected DataTable BuildFromCSV(string fileName)
        {
            ChartValues.Clear();
            DataTable dt = CSV_DataTable.ConvertCSVtoDataTable(fileName);

            for (int i = 1; i < dt.Rows.Count; i++)
            {
                ChartValues.Add(new MeasureModel
                {
                    ValueX = Convert.ToDouble(dt.Rows[i][0]),
                    ValueY = Convert.ToDouble(dt.Rows[i][1])
                });
            }
            return(dt);
        }