Пример #1
0
        /// <summary>
        /// Generates similar curve to original one
        /// </summary>
        /// <param name="points">Original curve</param>
        /// <returns></returns>
        public static List <PointF> GenerateCurve(List <PointF> points, double errorReduction)
        {
            List <PointF> autoCurve = new List <PointF>();
            float         error     = GetError(points) / (float)errorReduction;
            float         x;
            float         y;

            for (int i = 0; i < points.Count; i++)
            {
                float extra = 1.5F;
                //if (i == 0 || i == points.Count - 1)
                //{
                //    continue;
                //}
                //if (i == 0)
                //{
                //    //x = points[i].X + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    //y = points[i].Y + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    //x = points[i + 1].X - ((points[i + 1].X - points[i].X) / 2) + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    //y = points[i + 1].Y - ((points[i + 1].Y - points[i].Y) / 2) + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    x = points[i].X - ((points[i + 1].X - points[i].X) / 4) + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    y = points[i].Y - ((points[i + 1].Y - points[i].Y) / 4) + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //}
                //else if (i == 1 || i == points.Count - 2)
                //{
                //    //continue;
                //    extra = 0.6f;
                //    x = points[i].X + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    y = points[i].Y + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //}
                //else if (i == points.Count - 1)
                //{
                //    //x = points[i].X + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    //y = points[i].Y + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    //x = points[i - 1].X + ((points[i].X - points[i - 1].X) / 2) + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    //y = points[i - 1].Y + ((points[i].Y - points[i - 1].Y) / 2) + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    x = points[i].X + ((points[i].X - points[i - 1].X) / 4) + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //    y = points[i].Y + ((points[i].Y - points[i - 1].Y) / 4) + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //}
                //else
                {
                    x = points[i].X + (2 * (float)StaticRandom.RandomDouble() - 1) * error;
                    y = points[i].Y + (2 * (float)StaticRandom.RandomDouble() - 1) * error;
                }
                //float extra = 1;
                //if (i == 0 || i == points.Count - 1) extra = 1.6F;
                //else if (i == 1 || i == points.Count - 2) extra = 1.2F;
                //x = points[i].X + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                //y = points[i].Y + (2 * (float)StaticRandom.RandomDouble() - 1) * (error * extra);
                autoCurve.Add(new PointF(x, y));
            }
            return(autoCurve);
        }
Пример #2
0
        /// <summary>
        /// Generates false curves for input
        /// </summary>
        /// <param name="points"></param>
        /// <returns></returns>
        public static List <PointF> GenerateFalseCurve(List <PointF> points)
        {
            List <PointF> autoCurve = new List <PointF>();
            float         error     = GetError(points) * 5.5F;
            float         x;
            float         y;

            for (int i = 0; i < points.Count; i++)
            {
                x = points[i].X + (2 * (float)StaticRandom.RandomDouble() - 1) * error;
                y = points[i].Y + (2 * (float)StaticRandom.RandomDouble() - 1) * error;
                autoCurve.Add(new PointF(x, y));
            }
            return(autoCurve);
        }
Пример #3
0
        /// <summary>
        /// Creates default neural network accroding to settings
        /// </summary>
        private void InitializeNetwork()
        {
            double[][] thresholds = new double[][] { new double[m_hiddenLayerSize], new double[m_outputSize] };

            for (int i = 0; i < thresholds.Length; i++)
            {
                for (int j = 0; j < thresholds[i].Length; j++)
                {
                    thresholds[i][j] = StaticRandom.RandomDouble() * (-1);
                }
            }

            m_network = new Network(m_inputSize, new int[] { m_hiddenLayerSize, m_outputSize }, thresholds,
                                    new IActivationFunction[] { new HyperbolicTangentFunction(), new SigmoidFunction() });
        }