Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17663


Ignore:
Timestamp:
07/12/20 11:16:10 (4 years ago)
Author:
dleko
Message:

#2825 Initialize population size with the correct number (according to NSGA-III paper).

Location:
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/NSGA3.cs

    r17662 r17663  
    173173            Parameters.Add(new FixedValueParameter<IntValue>(SeedName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
    174174            Parameters.Add(new FixedValueParameter<BoolValue>(SetSeedRandomlyName, "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
    175             Parameters.Add(new FixedValueParameter<IntValue>(PopulationSizeName, "The size of the population of Individuals.", new IntValue(200)));
     175            Parameters.Add(new FixedValueParameter<IntValue>(PopulationSizeName, "The size of the population of Individuals.", new IntValue(ReferencePoint.GetNumberOfGeneratedReferencePoints(NumberOfObjectives))));
    176176            Parameters.Add(new FixedValueParameter<PercentValue>(CrossoverProbabilityName, "The probability that the crossover operator is applied on two parents.", new PercentValue(0.9)));
    177177            Parameters.Add(new FixedValueParameter<DoubleValue>(CrossoverContiguityName, "The contiguity value for the Simulated Binary Crossover that specifies how close a child should be to its parents (larger value means closer). The value must be greater than or equal than 0. Typical values are in the range [2;5]."));
     
    209209            base.Initialize(cancellationToken);
    210210
    211             InitFields();
    212211            InitResults();
    213212            InitReferencePoints();
     213            InitFields();
    214214            Analyze();
     215        }
     216
     217        private void InitReferencePoints()
     218        {
     219            // Generate reference points and add them to results
     220            ReferencePoints = ReferencePoint.GenerateReferencePoints(random, NumberOfObjectives);
     221            ResultsGeneratedReferencePoints = Utility.ConvertToDoubleMatrix(ReferencePoints);
    215222        }
    216223
     
    242249            Results.Add(new Result(GeneratedReferencePointsResultName, "The initially generated reference points", new DoubleMatrix()));
    243250            Results.Add(new Result(CurrentFrontResultName, "The Pareto Front", new DoubleMatrix()));
    244         }
    245 
    246         private void InitReferencePoints()
    247         {
    248             // Generate reference points and add them to results
    249             ReferencePoints = ReferencePoint.GenerateReferencePoints(random, NumberOfObjectives);
    250             ResultsGeneratedReferencePoints = Utility.ConvertToDoubleMatrix(ReferencePoints);
    251251        }
    252252
  • branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/ReferencePoint.cs

    r17661 r17663  
    4040
    4141        /// <summary>
     42        /// Returns the number of reference points that would be created when using <see
     43        /// cref="GenerateReferencePoints(IRandom, int)" />.
     44        /// </summary>
     45        /// <param name="nDim"></param>
     46        /// <returns></returns>
     47        internal static int GetNumberOfGeneratedReferencePoints(int nDim)
     48        {
     49            int outerDiv;
     50            int innerDiv;
     51            switch (nDim)
     52            {
     53                case 3:
     54                    outerDiv = 12;
     55                    innerDiv = 0;
     56                    break;
     57
     58                case 5:
     59                    outerDiv = 6;
     60                    innerDiv = 0;
     61                    break;
     62
     63                case 8:
     64                    outerDiv = 3;
     65                    innerDiv = 2;
     66                    break;
     67
     68                case 10:
     69                    outerDiv = 3;
     70                    innerDiv = 2;
     71                    break;
     72
     73                case 15:
     74                    outerDiv = 2;
     75                    innerDiv = 1;
     76                    break;
     77
     78                default:
     79                    return -1;
     80            }
     81
     82            return GetNumberOfGeneratedReferencePoints(nDim, outerDiv, innerDiv);
     83        }
     84
     85        internal static int GetNumberOfGeneratedReferencePoints(int nDim, int outerDiv, int innerDiv = 0)
     86        {
     87            return Utility.NCR(nDim + outerDiv - 1, outerDiv) + (innerDiv == 0 ? 0 : Utility.NCR(nDim + innerDiv - 1, innerDiv));
     88        }
     89
     90        /// <summary>
    4291        /// Generate reference points that are evenly distributed over a hyperplane with dimensions
    4392        /// <paramref name="nDim" /> - 1 with the sum of the values in all dimensions being equal to
     
    4594        /// -&gt; The number of inner divisions and outer divisions are determined based on the
    4695        /// values provided in the NSGA-III paper, chapter V: Results. If different dimensions are
    47         /// given, null is returned.
     96        /// given, a NotSupportedException is thrown.
    4897        /// </summary>
    4998        /// <param name="random">
     
    78127
    79128                default:
    80                     referencePoints = null;
    81                     break;
     129                    throw new NotSupportedException("Only the reference points for 3, 5, 8, 10 or 15 dimensions can be created.");
    82130            }
    83131
    84132            return referencePoints;
    85         }
    86 
    87         internal static List<ReferencePoint> GenerateReferencePoints(IRandom random, int nDim, int outerDiv)
    88         {
    89             return GenerateReferencePoints(random, nDim, outerDiv, 0);
    90133        }
    91134
     
    108151        /// not have inner reference points
    109152        /// </returns>
    110         internal static List<ReferencePoint> GenerateReferencePoints(IRandom random, int nDim, int outerDiv, int innerDiv)
     153        internal static List<ReferencePoint> GenerateReferencePoints(IRandom random, int nDim, int outerDiv, int innerDiv = 0)
    111154        {
    112155            if (nDim <= 0) throw new ArgumentException("nDim must be greater than 0");
Note: See TracChangeset for help on using the changeset viewer.