Пример #1
0
        /**
          * Creates a new instance of problem ZDT1.
          * @param numberOfVariables Number of variables.
          * @param solutionType The solution type must "Real", "BinaryReal, and "ArrayReal".
          */
        public ZDT1(String solutionType, int numberOfVariables)
        {
            NumberOfVariables = numberOfVariables;
            NumberOfObjectives = 2;
            NumberOfConstraints = 0;
            ProblemName = "ZDT1";

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

            // Establishes upper and lower limits for the variables
            for (int var = 0; var < NumberOfVariables; var++)
            {
                UpperLimit[var] = 0.0;
                UpperLimit[var] = 1.0;
            } // for

            if (string.Equals(solutionType, "BinaryReal", StringComparison.InvariantCultureIgnoreCase))
            {
                TypeOfSolution = new BinaryRealSolutionType(this);
            }
            else if (string.Equals(solutionType, "Real", StringComparison.InvariantCultureIgnoreCase))
            {
                TypeOfSolution = new RealSolutionType(this);
            }
            else if (string.Equals(solutionType, "ArrayReal", StringComparison.InvariantCultureIgnoreCase))
            {
                TypeOfSolution = new ArrayRealSolutionType(this);
            }
            else
            {
                throw new Exception("Error: solution type " + solutionType + " invalid");
            }
        }
Пример #2
0
        public DTLZ1(String solutionType,
                     int numberOfVariables,
                     int numberOfObjectives)
        {
            NumberOfVariables = numberOfVariables;
            NumberOfObjectives = numberOfObjectives;
            NumberOfConstraints = 0;
            ProblemName = "DTLZ1";

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

            if (string.Equals(solutionType, "BinaryReal", StringComparison.InvariantCultureIgnoreCase))
            {
                TypeOfSolution = new BinaryRealSolutionType(this);
            }
            else if (string.Equals(solutionType, "Real", StringComparison.InvariantCultureIgnoreCase))
            {
                TypeOfSolution = new RealSolutionType(this);
            }
            else
            {
                throw new Exception("Error: solution type " + solutionType + " invalid");
            }
        }