Exemple #1
0
        /// <summary>
        /// Constructor.
        /// Creates a new instance of the Kursawe problem.
        /// </summary>
        /// <param name="solutionType">The solution type must "Real", "BinaryReal, and "ArrayReal".</param>
        /// <param name="numberOfVariables">Number of variables of the problem</param>
        public Kursawe(string solutionType, int numberOfVariables)
        {
            NumberOfVariables   = numberOfVariables;
            NumberOfObjectives  = 2;
            NumberOfConstraints = 0;
            ProblemName         = "Kursawe";

            UpperLimit = new double[NumberOfVariables];
            LowerLimit = new double[NumberOfVariables];

            for (int i = 0; i < NumberOfVariables; i++)
            {
                LowerLimit[i] = -5.0;
                UpperLimit[i] = 5.0;
            }

            if (solutionType == "BinaryReal")
            {
                SolutionType = new BinaryRealSolutionType(this);
            }
            else if (solutionType == "Real")
            {
                SolutionType = new RealSolutionType(this);
            }
            else if (solutionType == "ArrayReal")
            {
                SolutionType = new ArrayRealSolutionType(this);
            }
            else
            {
                Console.WriteLine("Error: solution type " + solutionType + " is invalid");
                Logger.Log.Error("Error: solution type " + solutionType + " is invalid");
                Environment.Exit(-1);
            }
        }
Exemple #2
0
        /// <summary>
        /// Constructor
        /// Creates a default instance of the Fonseca problem
        /// </summary>
        /// <param name="solutionType">The solution type must "Real", "BinaryReal, ArrayReal, or ArrayRealC".</param>
        public Fonseca(string solutionType)
        {
            NumberOfVariables   = 3;
            NumberOfObjectives  = 2;
            NumberOfConstraints = 0;
            ProblemName         = "Fonseca";

            UpperLimit = new double[NumberOfVariables];
            LowerLimit = new double[NumberOfVariables];
            for (int var = 0; var < NumberOfVariables; var++)
            {
                LowerLimit[var] = 0.0;
                UpperLimit[var] = 2.0;
            }

            if (solutionType == "BinaryReal")
            {
                SolutionType = new BinaryRealSolutionType(this);
            }
            else if (solutionType == "Real")
            {
                SolutionType = new RealSolutionType(this);
            }
            else if (solutionType == "ArrayReal")
            {
                SolutionType = new ArrayRealSolutionType(this);
            }
            else
            {
                Console.WriteLine("Error: solution type " + solutionType + " is invalid");
                Logger.Log.Error("Error: solution type " + solutionType + " is invalid");
                Environment.Exit(-1);
            }
        }
Exemple #3
0
        /// <summary>
        /// Constructor.
        /// Creates a new ZDT3 problem instance.
        /// </summary>
        /// <param name="solutionType">The solution type must "Real" or "BinaryReal", and "ArrayReal".</param>
        /// <param name="numberOfVariables">Number of variables</param>
        public ZDT3(string solutionType, int numberOfVariables)
        {
            NumberOfVariables   = numberOfVariables;
            NumberOfObjectives  = 2;
            NumberOfConstraints = 0;
            ProblemName         = "ZDT3";

            UpperLimit = new double[NumberOfVariables];
            LowerLimit = new double[NumberOfVariables];

            for (int i = 0; i < NumberOfVariables; i++)
            {
                LowerLimit[i] = 0.0;
                UpperLimit[i] = 1.0;
            }

            if (solutionType == "BinaryReal")
            {
                SolutionType = new BinaryRealSolutionType(this);
            }
            else if (solutionType == "Real")
            {
                SolutionType = new RealSolutionType(this);
            }
            else if (solutionType == "ArrayReal")
            {
                SolutionType = new ArrayRealSolutionType(this);
            }
            else
            {
                Console.WriteLine("Error: solution type " + solutionType + " is invalid");
                Logger.Log.Error("Solution type " + solutionType + " is invalid");
                return;
            }
        }
        /// <summary>
        /// Constructor.
        /// Creates a new multiobjective problem instance.
        /// </summary>
        /// <param name="solutionType">The solution type must "Real" or "BinaryReal", and "ArrayReal".</param>
        /// <param name="numberOfVariables">Number of variables</param>
        public NSGAIIProblem(string solutionType, MOO comp, int solutionsCounter)
        {
            this.component      = comp;
            NumberOfVariables   = comp.readSlidersList().Count;
            NumberOfObjectives  = comp.objectives.Count;
            NumberOfConstraints = 0;
            ProblemName         = "Multiobjective";

            // Log
            comp.LogAddMessage("Number of Variables = " + NumberOfVariables);
            comp.LogAddMessage("Number of Objectives = " + NumberOfObjectives);
            comp.LogAddMessage("Number of Constraints = " + NumberOfConstraints);


            UpperLimit = new double[NumberOfVariables];
            LowerLimit = new double[NumberOfVariables];

            for (int i = 0; i < NumberOfVariables; i++)
            {
                GH_NumberSlider curSlider = comp.readSlidersList()[i];

                LowerLimit[i] = (double)curSlider.Slider.Minimum;
                UpperLimit[i] = (double)curSlider.Slider.Maximum;
            }

            if (solutionType == "BinaryReal")
            {
                SolutionType = new BinaryRealSolutionType(this);
            }
            else if (solutionType == "Real")
            {
                SolutionType = new RealSolutionType(this);
            }
            else if (solutionType == "ArrayReal")
            {
                SolutionType = new ArrayRealSolutionType(this);
            }
            else
            {
                Console.WriteLine("Error: solution type " + solutionType + " is invalid");
                //Logger.Log.Error("Solution type " + solutionType + " is invalid");
                return;
            }

            // Log
            comp.LogAddMessage("Solution Type = " + solutionType);
        }