- Timestamp:
- 04/20/10 19:17:14 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Operators/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Operators/3.3/HeuristicLab.Optimization.Operators-3.3.csproj
r3425 r3451 83 83 <Compile Include="ProbabilisticQualityComparator.cs" /> 84 84 <Compile Include="ResultsCollector.cs" /> 85 <Compile Include="SASEGASAReunificator.cs" /> 85 86 <Compile Include="SquareRootDiscreteDoubleValueModifier.cs" /> 86 87 <Compile Include="DiscreteDoubleValueModifier.cs" /> -
trunk/sources/HeuristicLab.Optimization.Operators/3.3/SASEGASAReunificator.cs
r1529 r3451 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Text;24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab.Data; 26 using HeuristicLab.Operators; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 28 namespace HeuristicLab. Evolutionary{29 namespace HeuristicLab.Optimization.Operators { 29 30 /// <summary> 30 31 /// Joins all sub sub scopes of a specified scope, reduces the number of sub 31 32 /// scopes by 1 and uniformly partitions the sub sub scopes again, maintaining the order. 32 33 /// </summary> 33 public class SASEGASAReunificator : OperatorBase { 34 /// <inheritdoc select="summary"/> 35 public override string Description { 36 get { return @"TODO\r\nOperator description still missing ..."; } 37 } 34 /*[Item("SASEGASAReunificator", "This operator merges the villages in a migration phase and redistributes the individuals. It is implemented as described in Affenzeller, M. et al. 2009. Genetic Algorithms and Genetic Programming - Modern Concepts and Practical Applications, CRC Press.")] 35 [StorableClass] 36 public class SASEGASAReunificator : SingleSuccessorOperator, IMigrator { 38 37 39 38 /// <summary> … … 44 43 /// <param name="scope">The current scope whose sub scopes to reduce.</param> 45 44 /// <returns><c>null</c>.</returns> 46 public override IOperation Apply(IScope scope) { 47 int subScopes = scope.SubScopes.Count; 48 if (subScopes <= 1) 45 public override IOperation Apply() { 46 IScope scope = ExecutionContext.Scope; 47 int villageCount = scope.SubScopes.Count; 48 if (villageCount <= 1) 49 49 throw new InvalidOperationException("SASEGASA reunification requires 2 or more sub-scopes"); 50 50 51 // get all sub-sub-scopes52 IList<IScope> subSubScopes= new List<IScope>();53 for (int i = 0; i < scope.SubScopes.Count; i++) {54 while (scope.SubScopes[i].SubScopes .Count > 0) {55 subSubScopes.Add(scope.SubScopes[i].SubScopes[0]);56 scope.SubScopes[i]. RemoveSubScope(scope.SubScopes[i].SubScopes[0]);51 // get all villages 52 IList<IScope> population = new List<IScope>(); 53 for (int i = 0; i < villageCount; i++) { 54 while (scope.SubScopes[i].SubScopes[0].SubScopes.Count > 0) { 55 population.Add(scope.SubScopes[i].SubScopes[0].SubScopes[0]); 56 scope.SubScopes[i].SubScopes.Remove(scope.SubScopes[i].SubScopes[0].SubScopes[0]); 57 57 } 58 scope.SubScopes[i].SubScopes.Clear(); 58 59 } 59 60 60 // reduce number of sub-scopes by 1 and partition sub-sub-scopes again 61 scope.RemoveSubScope(scope.SubScopes[scope.SubScopes.Count - 1]); 62 subScopes--; 63 int subSubScopesCount = subSubScopes.Count / subScopes; 64 for (int i = 0; i < subScopes; i++) { 65 for (int j = 0; j < subSubScopesCount; j++) { 66 scope.SubScopes[i].AddSubScope(subSubScopes[0]); 67 subSubScopes.RemoveAt(0); 61 // reduce number of villages by 1 and partition the population again 62 scope.SubScopes.Remove(scope.SubScopes[scope.SubScopes.Count - 1]); 63 villageCount--; 64 int populationPerVillage = population.Count / villageCount; 65 for (int i = 0; i < villageCount; i++) { 66 scope.SubScopes[i].SubScopes.Add(new Scope()); 67 scope.SubScopes[i].SubScopes.Add(new Scope()); 68 for (int j = 0; j < populationPerVillage; j++) { 69 scope.SubScopes[i].SubScopes[1].SubScopes.Add(population[0]); 70 population.RemoveAt(0); 68 71 } 69 72 } 70 73 71 74 // add remaining sub-sub-scopes to last sub-scope 72 while ( subSubScopes.Count > 0) {73 scope.SubScopes[scope.SubScopes.Count - 1]. AddSubScope(subSubScopes[0]);74 subSubScopes.RemoveAt(0);75 while (population.Count > 0) { 76 scope.SubScopes[scope.SubScopes.Count - 1].SubScopes[1].SubScopes.Add(population[0]); 77 population.RemoveAt(0); 75 78 } 76 79 77 return null;80 return base.Apply(); 78 81 } 79 } 82 }*/ 80 83 }
Note: See TracChangeset
for help on using the changeset viewer.