Changeset 12171
- Timestamp:
- 03/10/15 10:00:41 (10 years ago)
- Location:
- branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsGeneticAlgorithmMainLoop.cs
r12162 r12171 79 79 var incrementNextInit = new IntCounter() { Name = "Incr. NextInit" }; 80 80 var checkInitFinished = new Comparator() { Name = "DoInit = NextInit >= PopulationSize" }; 81 var createWorkingScope = new BestSelector(); 82 var workingScopeProcessor = new SubScopesProcessor() { Name = "Working Scope Processor" }; 81 var workingScopeProcessor = new NamedSubScopeProcessor() { Name = "WorkingScope Processor" }; 83 82 var createRandomIndividual = new SolutionsCreator() { Name = "Create random Individual" }; 84 83 var initializeAgeProcessor = new UniformSubScopesProcessor(); 85 84 var initializeAge = new Assigner() { Name = "Initialize Age" }; 85 var removeEmptySubscope = new SubScopesRemover() { Name = "Remove empty subscope (from solutioncreator)" }; 86 86 var selectRandomTargetIndex = new RandomIntAssigner(); 87 87 var matingPoolCreator = new SteadyStateMatingPoolCreator() { Name = "Create MatingPool" }; … … 92 92 var mainOperator = new AlpsSsGeneticAlgorithmMainOperator(); 93 93 var reactivateInit = new Assigner() { Name = "DoInit = true" }; 94 var resetNextIn dex= new Assigner() { Name = "NextInit = 1" };94 var resetNextInit = new Assigner() { Name = "NextInit = 1" }; 95 95 var resetTargetIndex = new Assigner() { Name = "TargetIndex = 0" }; 96 var clearMatingPool = new SubScopesRemover() { Name = "Clear WorkingScope" };97 96 var tryMoveUp = new AlpsSsMover() { Name = "Try Move Up" }; 98 97 var incrementEvaluations = new IntCounter() { Name = "incr. EvaluatedSolutions" }; … … 121 120 122 121 randomScopeProcessor.Operator = isLayerZeroComperator; 122 // TODO move to old individuals 123 123 randomScopeProcessor.Successor = incrIterations; 124 124 … … 150 150 checkInitFinished.Comparison = new Comparison(ComparisonType.GreaterOrEqual); 151 151 checkInitFinished.ResultParameter.ActualName = "DoInit"; 152 checkInitFinished.Successor = createWorkingScope; 153 154 createWorkingScope.NumberOfSelectedSubScopesParameter.Value = new IntValue(0); 155 createWorkingScope.CopySelected = new BoolValue(false); 156 createWorkingScope.Successor = workingScopeProcessor; 157 158 workingScopeProcessor.Operators.Add(createRandomIndividual); 159 workingScopeProcessor.Operators.Add(new EmptyOperator()); 152 checkInitFinished.Successor = workingScopeProcessor; 153 154 workingScopeProcessor.Operator = createRandomIndividual; 155 workingScopeProcessor.TargetScopeParameter.ActualName = "WorkingScope"; 160 156 161 157 createRandomIndividual.NumberOfSolutions = new IntValue(1); … … 163 159 164 160 initializeAgeProcessor.Operator = initializeAge; 161 initializeAgeProcessor.Successor = removeEmptySubscope; 165 162 166 163 initializeAge.LeftSideParameter.ActualName = "EvalsCreated"; … … 192 189 validParentsBranch.FalseBranch = reactivateInit; 193 190 194 reactivateInit.Successor = resetNextIn dex;191 reactivateInit.Successor = resetNextInit; 195 192 reactivateInit.LeftSideParameter.ActualName = "DoInit"; 196 193 reactivateInit.RightSideParameter.Value = new BoolValue(true); 197 194 198 resetNextIndex.Successor = resetTargetIndex; 199 resetNextIndex.LeftSideParameter.ActualName = "NextIndex"; 200 resetNextIndex.RightSideParameter.Value = new IntValue(1); 201 202 resetTargetIndex.Successor = clearMatingPool; 195 resetNextInit.Successor = resetTargetIndex; 196 resetNextInit.LeftSideParameter.ActualName = "NextInit"; 197 resetNextInit.RightSideParameter.Value = new IntValue(1); 198 203 199 resetTargetIndex.LeftSideParameter.ActualName = "TargetIndex"; 204 200 resetTargetIndex.RightSideParameter.Value = new IntValue(0); 205 206 clearMatingPool.Successor = createRandomIndividual; 201 resetTargetIndex.Successor = createRandomIndividual; 207 202 208 203 tryMoveUp.Successor = incrementEvaluations; -
branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/SteadyStateMatingPoolCreator.cs
r12159 r12171 35 35 get { return (ILookupParameter<IScope>)Parameters["WorkingScope"]; } 36 36 } 37 private ILookupParameter<IScope> LayersParameter { 38 get { return (ILookupParameter<IScope>)Parameters["Layers"]; } 39 } 37 40 private ILookupParameter<IntValue> LayerParameter { 38 41 get { return (ILookupParameter<IntValue>)Parameters["Layer"]; } 42 } 43 private ILookupParameter<IntArray> AgeLimitsParameter { 44 get { return (ILookupParameter<IntArray>)Parameters["AgeLimits"]; } 45 } 46 private ILookupParameter<IntValue> NumberOfLayersParameter { 47 get { return (ILookupParameter<IntValue>)Parameters["NumberOfLayers"]; } 48 } 49 private ILookupParameter<IntValue> EvaluatedSolutionsParameter { 50 get { return (ILookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 51 } 52 private ILookupParameter<IntValue> PopulationSizeParameter { 53 get { return (ILookupParameter<IntValue>)Parameters["PopulationSize"]; } 39 54 } 40 55 … … 50 65 : base() { 51 66 Parameters.Add(new LookupParameter<IScope>("WorkingScope")); 67 Parameters.Add(new LookupParameter<IScope>("Layers")); 52 68 Parameters.Add(new LookupParameter<IntValue>("Layer")); 69 Parameters.Add(new LookupParameter<IntArray>("AgeLimits")); 70 Parameters.Add(new LookupParameter<IntValue>("NumberOfLayers")); 71 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions")); 72 Parameters.Add(new LookupParameter<IntValue>("PopulationSize")); 73 53 74 } 54 75 … … 56 77 int layerNumber = LayerParameter.ActualValue.Value; 57 78 var workingScope = WorkingScopeParameter.ActualValue; 79 var layers = LayersParameter.ActualValue; 80 var ageLimits = AgeLimitsParameter.ActualValue; 81 int numberOfLayers = NumberOfLayersParameter.ActualValue.Value; 82 int evaluations = EvaluatedSolutionsParameter.ActualValue.Value; 83 int popSize = PopulationSizeParameter.ActualValue.Value; 58 84 59 var currentLayer = ExecutionContext.Scope; 60 foreach (var individual in currentLayer.SubScopes) { 61 workingScope.SubScopes.Add((IScope)individual.Clone()); 85 var currentLayer = layers.SubScopes[layerNumber].SubScopes; 86 var prevLayer = layerNumber > 0 ? layers.SubScopes[layerNumber - 1].SubScopes : Enumerable.Empty<IScope>(); 87 88 var ageLimit = layerNumber < numberOfLayers - 1 ? ageLimits[layerNumber] : int.MaxValue; 89 90 var matingPool = 91 from individual in currentLayer.Union(prevLayer) 92 let evalsCreated = ((IntValue)individual.Variables["EvalsCreated"].Value).Value 93 let age = (evaluations - evalsCreated) / popSize 94 where age < ageLimit 95 select (IScope)individual.Clone(); 96 97 foreach (var individual in matingPool) { 98 workingScope.SubScopes.Add(individual); 62 99 } 63 64 if (layerNumber > 0) {65 var layers = currentLayer.Parent;66 var prevLayer = layers.SubScopes[layerNumber - 1];67 68 foreach (var individual in prevLayer.SubScopes) {69 workingScope.SubScopes.Add((IScope)individual.Clone());70 }71 }72 73 100 return base.Apply(); 74 101 }
Note: See TracChangeset
for help on using the changeset viewer.