Changeset 17663
- Timestamp:
- 07/12/20 11:16:10 (4 years ago)
- 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 173 173 Parameters.Add(new FixedValueParameter<IntValue>(SeedName, "The random seed used to initialize the new pseudo random number generator.", new IntValue(0))); 174 174 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)))); 176 176 Parameters.Add(new FixedValueParameter<PercentValue>(CrossoverProbabilityName, "The probability that the crossover operator is applied on two parents.", new PercentValue(0.9))); 177 177 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].")); … … 209 209 base.Initialize(cancellationToken); 210 210 211 InitFields();212 211 InitResults(); 213 212 InitReferencePoints(); 213 InitFields(); 214 214 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); 215 222 } 216 223 … … 242 249 Results.Add(new Result(GeneratedReferencePointsResultName, "The initially generated reference points", new DoubleMatrix())); 243 250 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 results249 ReferencePoints = ReferencePoint.GenerateReferencePoints(random, NumberOfObjectives);250 ResultsGeneratedReferencePoints = Utility.ConvertToDoubleMatrix(ReferencePoints);251 251 } 252 252 -
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/ReferencePoint.cs
r17661 r17663 40 40 41 41 /// <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> 42 91 /// Generate reference points that are evenly distributed over a hyperplane with dimensions 43 92 /// <paramref name="nDim" /> - 1 with the sum of the values in all dimensions being equal to … … 45 94 /// -> The number of inner divisions and outer divisions are determined based on the 46 95 /// 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. 48 97 /// </summary> 49 98 /// <param name="random"> … … 78 127 79 128 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."); 82 130 } 83 131 84 132 return referencePoints; 85 }86 87 internal static List<ReferencePoint> GenerateReferencePoints(IRandom random, int nDim, int outerDiv)88 {89 return GenerateReferencePoints(random, nDim, outerDiv, 0);90 133 } 91 134 … … 108 151 /// not have inner reference points 109 152 /// </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) 111 154 { 112 155 if (nDim <= 0) throw new ArgumentException("nDim must be greater than 0");
Note: See TracChangeset
for help on using the changeset viewer.