public static double set(int functionType, int optimizationType, double x)
        {
            double y;

            #region switch cases
            switch (optimizationType)
            {
            case 0:
            {
                switch (functionType)
                {
                case 1:
                {
                    y = -Equation.F1x(x);
                }
                break;

                case 2:
                {
                    y = -Equation.F2x(x);
                }
                break;

                case 3:
                {
                    y = -Equation.F3x(x);
                }
                break;

                case 4:
                {
                    y = -Equation.F4x(x);
                }
                break;

                case 5:
                {
                    y = -Equation.F5x(x);
                }
                break;

                default:
                {
                    y = -Equation.F1x(x);
                }
                break;
                }
            }
            break;

            case 1:
            {
                switch (functionType)
                {
                case 1:
                {
                    y = Equation.F1x(x);
                }
                break;

                case 2:
                {
                    y = Equation.F2x(x);
                }
                break;

                case 3:
                {
                    y = Equation.F3x(x);
                }
                break;

                case 4:
                {
                    y = Equation.F4x(x);
                }
                break;

                case 5:
                {
                    y = Equation.F5x(x);
                }
                break;

                default:
                {
                    y = Equation.F1x(x);
                }
                break;
                }
            }
            break;

            default:
            {
                switch (functionType)
                {
                case 1:
                {
                    y = -Equation.F1x(x);
                }
                break;

                case 2:
                {
                    y = -Equation.F2x(x);
                }
                break;

                case 3:
                {
                    y = -Equation.F3x(x);
                }
                break;

                case 4:
                {
                    y = -Equation.F4x(x);
                }
                break;

                case 5:
                {
                    y = -Equation.F5x(x);
                }
                break;

                default:
                {
                    y = -Equation.F1x(x);
                }
                break;
                }
            }
            break;
            }
            #endregion
            return(y);
        }
Example #2
0
        private void graphTimer_Tick(object sender, EventArgs e)
        {
            rtbInfo.AppendText(nog_count + ") Xavg: " + Math.Round(myGA.chromoValue.Average(), 2) + "\tFxavg  " + Math.Round(Equation.F3x(myGA.chromoValue.Average()), 2) + "\tFitness  " + Math.Round(myGA.chromoFitness.Average(), 2) + "\n");

            GAPointsRPPL.Clear();
            for (int i = 0; i < myGA.populationSize; i++)
            {
                GAPointsRPPL.Add(myGA.chromoValue[i], Equation.set(myGA.functionType, myGA.chromoValue[i]));
            }

            PCavgPointsRPPL.Add(nog_count, myGA.chromoValue.Average());
            PCmaxPointsRPPL.Add(nog_count, myGA.chromoValue.Max());

            //PCavgPointsRPPL.Add(nog_count, myGA.chromoFitness.Average());
            //PCmaxPointsRPPL.Add(nog_count, myGA.chromoFitness.Max());

            zgcFunction.Invalidate();
            zgcPerformance.Invalidate();
        }