Changeset 4067
- Timestamp:
- 07/22/10 00:11:15 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/CrowdedComparisonSorter.cs
r4040 r4067 58 58 int[] indices = Enumerable.Range(0, size).ToArray(); 59 59 60 Array.Sort(indices, new CustomComparer(ranks, distances));61 60 IScope[] scopes = ExecutionContext.Scope.SubScopes.ToArray(); 62 Array.Sort(indices, scopes );61 Array.Sort(indices, scopes, new CustomComparer(ranks, distances)); 63 62 ExecutionContext.Scope.SubScopes.Clear(); 64 63 ExecutionContext.Scope.SubScopes.AddRange(scopes); -
trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/CrowdingDistanceAssignment.cs
r4017 r4067 70 70 double minQuality = qualities[0][m]; 71 71 double maxQuality = qualities[populationSize - 1][m]; 72 for (int i = 2; i < populationSize - 1; i++) {72 for (int i = 1; i < populationSize - 1; i++) { 73 73 distances[i].Value += (qualities[i + 1][m] - qualities[i - 1][m]) / (maxQuality - minQuality); 74 74 } … … 82 82 for (int i = 0; i < populationSize; i++) 83 83 distances[i] = new DoubleValue(0); 84 85 CrowdingDistanceParameter.ActualValue = new ItemArray<DoubleValue>(distances); 84 86 85 87 Apply(qualities, distances); 86 88 87 CrowdingDistanceParameter.ActualValue = new ItemArray<DoubleValue>(distances);88 89 return base.Apply(); 89 90 } -
trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/FastNonDominatedSort.cs
r4045 r4067 72 72 for (int pI = 0; pI < populationSize - 1; pI++) { 73 73 IScope p = scope.SubScopes[pI]; 74 dominatedScopes[p] = new List<int>(); 74 if (!dominatedScopes.ContainsKey(p)) 75 dominatedScopes[p] = new List<int>(); 75 76 for (int qI = pI + 1; qI < populationSize; qI++) { 76 77 DominationResult test = Dominates(qualities[pI], qualities[qI], maximization); … … 80 81 } else if (test == DominationResult.IsDominated) { 81 82 dominationCounter[pI] += 1; 83 if (!dominatedScopes.ContainsKey(scope.SubScopes[qI])) 84 dominatedScopes.Add(scope.SubScopes[qI], new List<int>()); 82 85 dominatedScopes[scope.SubScopes[qI]].Add(pI); 83 86 } … … 98 101 ScopeList nextFront = new ScopeList(); 99 102 foreach (IScope p in fronts[i]) { 100 for (int k = 0; k < dominatedScopes[p].Count; k++) { 101 int dominatedScope = dominatedScopes[p][k]; 102 dominationCounter[k] -= 1; 103 if (dominationCounter[k] == 0) { 104 rank[k] = new IntValue(i + 1); 105 nextFront.Add(scope.SubScopes[k]); 103 if (dominatedScopes.ContainsKey(p)) { 104 for (int k = 0; k < dominatedScopes[p].Count; k++) { 105 int dominatedScope = dominatedScopes[p][k]; 106 dominationCounter[dominatedScope] -= 1; 107 if (dominationCounter[dominatedScope] == 0) { 108 rank[dominatedScope] = new IntValue(i + 1); 109 nextFront.Add(scope.SubScopes[dominatedScope]); 110 } 106 111 } 107 112 } -
trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs
r4045 r4067 208 208 foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op); 209 209 ParameterizeSolutionsCreator(); 210 ParameterizeRankAndCrowdingSorter(); 210 211 ParameterizeMainLoop(); 211 212 ParameterizeSelectors(); … … 226 227 ParameterizeStochasticOperator(Problem.Evaluator); 227 228 ParameterizeSolutionsCreator(); 229 ParameterizeRankAndCrowdingSorter(); 228 230 ParameterizeMainLoop(); 229 231 ParameterizeSelectors(); … … 251 253 } 252 254 private void Evaluator_QualitiesParameter_ActualNameChanged(object sender, EventArgs e) { 255 ParameterizeRankAndCrowdingSorter(); 253 256 ParameterizeMainLoop(); 254 257 ParameterizeSelectors(); … … 269 272 SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 270 273 SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name; 274 } 275 private void ParameterizeRankAndCrowdingSorter() { 276 RankAndCrowdingSorter.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 277 RankAndCrowdingSorter.QualitiesParameter.ActualName = Problem.Evaluator.QualitiesParameter.ActualName; 271 278 } 272 279 private void ParameterizeMainLoop() {
Note: See TracChangeset
for help on using the changeset viewer.