/// <summary>
        /// Converts from the specified value to the intended conversion type of the converter.
        /// </summary>
        /// <param name="context">An object that provides a format context.</param>
        /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param>
        /// <param name="value">The value to convert to the type of this converter.</param>
        /// <returns>
        /// The converted value.
        /// </returns>
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            List <string> result = ((string)value).Split(',').ToList();

            for (int j = 0; j < result.Count; j++)
            {
                var point = result[j];
                if (string.IsNullOrEmpty(point))
                {
                    result[j] = "0";
                }
            }
            if (result.Count % 2 != 0)
            {
                result.Add("0");
            }
            PointsCollection collection = new PointsCollection();

            for (int i = 0; i < result.Count; i += 2)
            {
                collection.Add(new ChartPoint()
                {
                    XValue = double.Parse(result[i].ToString(CultureInfo.InvariantCulture)), YValue = double.Parse(result[i + 1].ToString(CultureInfo.InvariantCulture))
                });
            }
            return(collection);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the points from values.
        /// </summary>
        /// <param name="xValues">The x values.</param>
        /// <param name="yValues">The y values.</param>
        /// <returns></returns>
        protected PointsCollection GetPointsFromValues(List <double> xValues, List <double> yValues)
        {
            PointsCollection tempPoints = new PointsCollection();

            for (int i = 0; (i < xValues.Count && i < yValues.Count); i++)
            {
                ChartPoint point = new ChartPoint()
                {
                    XValue = xValues[i], YValue = yValues[i]
                };
                tempPoints.Add(point);
            }
            return(tempPoints);
        }
        public void SetData(short[] data)
        {
            PointsCollection = new PointsCollection();

            for (int i = 0; i < data.Length; i++)
            {
                PointsCollection.Add(new DoublePoint()
                {
                    Data = i, Value = data[i]
                });
            }

            ((LineSeries)(Chart.Series[0])).Points = PointsCollection;
        }
 /// <summary>
 /// Converts from the specified value to the intended conversion type of the converter.
 /// </summary>
 /// <param name="context">An object that provides a format context.</param>
 /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param>
 /// <param name="value">The value to convert to the type of this converter.</param>
 /// <returns>
 /// The converted value.
 /// </returns>
 public override object ConvertFrom(ITypeDescriptorContext context,System.Globalization.CultureInfo culture, object value)
 {
     List<string> result = ((string)value).Split(',').ToList();
     for (int j=0;j<result.Count;j++)
     {
         var point = result[j];
         if (string.IsNullOrEmpty(point))
             result[j] = "0";
     }
     if (result.Count % 2 != 0)
         result.Add("0");
     PointsCollection collection = new PointsCollection();
     for (int i = 0; i < result.Count; i += 2)
     {
         collection.Add(new ChartPoint() { XValue = double.Parse(result[i].ToString(CultureInfo.InvariantCulture)), YValue = double.Parse(result[i + 1].ToString(CultureInfo.InvariantCulture)) });
     }
     return collection;
 }
 public GeneticAlgorithmParametersViewModel()
 {
     _geneticAlgorithm             = new CubeGraphGeneticAlgorithm(Graph.FromFile(@"..\..\GraphData.txt"));
     _startGeneticAlgorithmCommand = new Command <object>((mockParams) =>
     {
         new Task(() =>
         {
             _geneticAlgorithm.Execute(_geneticParameters, (progress) => ProgressValue = progress);
             var averageFitness = new PointsCollection();
             var maxFitness     = new PointsCollection();
             var minFitness     = new PointsCollection();
             var maxPoints      = _geneticAlgorithm.History.Select((historyItem) => new DoublePoint()
             {
                 Data = historyItem.Generation, Value = historyItem.BestOrganismFitness
             });
             foreach (var point in maxPoints)
             {
                 maxFitness.Add(point);
             }
             var minPoints = _geneticAlgorithm.History.Select((historyItem) => new DoublePoint()
             {
                 Data = historyItem.Generation, Value = historyItem.WorstOrganismFitness
             });
             foreach (var point in minPoints)
             {
                 minFitness.Add(point);
             }
             var averagePoints = _geneticAlgorithm.History.Select((historyItem) => new DoublePoint()
             {
                 Data = historyItem.Generation, Value = historyItem.AverageOrganismFitness
             });
             foreach (var point in averagePoints)
             {
                 averageFitness.Add(point);
             }
             AverageFitness = averageFitness;
             MinFitness     = minFitness;
             MaxFitness     = maxFitness;
             NotifyPropertyChanged(() => MaxGridValue);
         }).Start();
     });
 }
Beispiel #6
0
        public PointsCollection Generate()
        {
            PointsCollection collection = new PointsCollection();
            DateTime date = new DateTime(2009, 1, 1);
            double value = 1000;
            for (int i = 0; i < this.DataCount; i++)
            {
                collection.Add(new DoublePoint() { Data = i, Value = value });

                if (randomNumber.NextDouble() > .5)
                {
                    value += randomNumber.NextDouble();
                }
                else
                {
                    value -= randomNumber.NextDouble();
                }
            }
            return collection;
        }
Beispiel #7
0
        public void InitializeChart(int[] values)
        {
            chart.YAxis.MaxValue        = values.Max() + (values.Max() * 0.05);
            chart.XAxis.MaxValue        = values.Length;
            chart.XAxis.MinorTicksCount = values.Length / 8;
            SeriesCollection series = new SeriesCollection()
            {
                new ColumnSeries()
            };
            var points = new PointsCollection();

            for (int i = 0; i < values.Length; i++)
            {
                points.Add(new DoublePoint()
                {
                    Data  = i,
                    Value = values[i]
                });
            }
            series[0].Points = points;
            chart.Series     = series;
        }
Beispiel #8
0
        public PointsCollection Generate()
        {
            PointsCollection collection = new PointsCollection();
            DateTime         date       = new DateTime(2009, 1, 1);
            double           value      = 1000;

            for (int i = 0; i < this.DataCount; i++)
            {
                collection.Add(new DoublePoint()
                {
                    Data = i, Value = value
                });

                if (randomNumber.NextDouble() > .5)
                {
                    value += randomNumber.NextDouble();
                }
                else
                {
                    value -= randomNumber.NextDouble();
                }
            }
            return(collection);
        }
Beispiel #9
0
 public void AddPoint(Point point)
 {
     PointsCollection.Add(point);
 }
Beispiel #10
0
 protected PointsCollection GetPointsFromValues(List<double> xValues,List<double> yValues)
 {
     PointsCollection tempPoints = new PointsCollection();
     for (int i = 0; (i < xValues.Count && i < yValues.Count); i++)
     {
         ChartPoint point = new ChartPoint() { XValue = xValues[i], YValue = yValues[i] };
         tempPoints.Add(point);
     }
     return tempPoints;
 }