Changeset 12035 for branches/ALPS
- Timestamp:
- 02/18/15 15:39:21 (10 years ago)
- Location:
- branches/ALPS
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithm.cs
r12018 r12035 69 69 get { return (IValueParameter<IntValue>)Parameters["NumberOfLayers"]; } 70 70 } 71 private IValueParameter<Int Value> PopulationSizeParameter {72 get { return (IValueParameter<Int Value>)Parameters["PopulationSize"]; }71 private IValueParameter<IntArray> PopulationSizeParameter { 72 get { return (IValueParameter<IntArray>)Parameters["PopulationSize"]; } 73 73 } 74 74 private IValueParameter<IntValue> MaximumGenerationsParameter { … … 129 129 } 130 130 131 public Int ValuePopulationSize {131 public IntArray PopulationSize { 132 132 get { return PopulationSizeParameter.Value; } 133 133 set { PopulationSizeParameter.Value = value; } … … 216 216 Parameters.Add(new ValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer())); 217 217 Parameters.Add(new ValueParameter<IntValue>("NumberOfLayers", "The number of layers.", new IntValue(5))); 218 Parameters.Add(new ValueParameter<Int Value>("PopulationSize", "The size of the population of solutions each layer.", new IntValue(20)));218 Parameters.Add(new ValueParameter<IntArray>("PopulationSize", "The size of the population of solutions each layer.", new IntArray(new[] { 5, 10, 20, 50, 100 }))); 219 219 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(1000))); 220 220 Parameters.Add(new ValueParameter<AgingScheme>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new AgingScheme(AgingSchemes.Polynomial))); … … 231 231 var globalRandomCreator = new RandomCreator(); 232 232 var layer0Creator = new SubScopesCreator() { Name = "Create Layer Zero" }; 233 var layer0Processor = new SubScopesProcessor();233 var layer0Processor = new LayerUniformSubScopesProcessor(); 234 234 var localRandomCreator = new LocalRandomCreator(); 235 235 var layerVariableCreator = new VariableCreator(); … … 253 253 layer0Creator.Successor = layer0Processor; 254 254 255 layer0Processor.Operator s.Add(localRandomCreator);255 layer0Processor.Operator = localRandomCreator; 256 256 layer0Processor.Successor = initializeGlobalEvaluatedSolutions; 257 257 … … 394 394 private void Initialize() { 395 395 PopulationSizeParameter.ValueChanged += PopulationSizeParameter_ValueChanged; 396 PopulationSize.ValueChanged += PopulationSize_ValueChanged;396 //PopulationSize.ValueChanged += PopulationSize_ValueChanged; TODO 397 397 ElitesParameter.ValueChanged += ElitesParameter_ValueChanged; 398 398 Elites.ValueChanged += Elites_ValueChanged; … … 421 421 } 422 422 private void ParameterizeSelectors() { 423 423 424 foreach (var selector in SelectorParameter.ValidValues) { 424 425 selector.CopySelected = new BoolValue(true); 425 selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSize.Value - Elites.Value)); 426 // Explicit setting of NumberOfSelectedSubScopesParameter is not required anymore because the NumberOfSelectedSubScopesCalculator calculates it itself 427 //selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSize - Elites.Value)); 426 428 selector.NumberOfSelectedSubScopesParameter.Hidden = true; 427 429 ParameterizeStochasticOperatorForLayer(selector); -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithmMainLoop.cs
r12018 r12035 80 80 var resultsCollector = new ResultsCollector(); 81 81 var matingPoolCreator = new MatingPoolCreator() { Name = "Create Mating Pools" }; 82 var matingPoolProcessor = new UniformSubScopesProcessor();82 var matingPoolProcessor = new LayerUniformSubScopesProcessor(); 83 83 var initializeLayer = new Assigner() { Name = "Reset LayerEvaluatedSolutions" }; 84 84 var mainOperator = CreatePreparedGeneticAlgorithmMainLoop(); … … 162 162 private GeneticAlgorithmMainLoop CreatePreparedGeneticAlgorithmMainLoop() { 163 163 var mainLoop = new GeneticAlgorithmMainLoop(); 164 var numberOfSelectedSubScopesCalculator = new NumberOfSelectedSubScopesCalculator(); 164 165 var selector = mainLoop.OperatorGraph.Iterate().OfType<Placeholder>().First(o => o.OperatorParameter.ActualName == "Selector"); 165 166 var crossover = mainLoop.OperatorGraph.Iterate().OfType<Placeholder>().First(o => o.OperatorParameter.ActualName == "Crossover"); … … 167 168 var elitesMerger = mainLoop.OperatorGraph.Iterate().OfType<MergingReducer>().First(); 168 169 169 // Operator starts with selector 170 mainLoop.OperatorGraph.InitialOperator = selector; 170 // Operator starts with numberOfSelectedSubScopesCalculator 171 mainLoop.OperatorGraph.InitialOperator = numberOfSelectedSubScopesCalculator; 172 numberOfSelectedSubScopesCalculator.Successor = selector; 171 173 172 174 // Insert AgeCalculator between crossover and its successor -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/EldersEmigrator.cs
r12018 r12035 56 56 var eldersSelector = new EldersSelector(); 57 57 var shiftToRightMigrator = new ShiftToRightMigrator(); 58 var mergingProsessor = new UniformSubScopesProcessor();58 var mergingProsessor = new LayerUniformSubScopesProcessor(); 59 59 var mergingReducer = new MergingReducer(); 60 60 var subScopesCounter = new SubScopesCounter(); -
branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/HeuristicLab.Algorithms.ALPS-3.3.csproj
r11677 r12035 93 93 <Compile Include="LastSubScopeCloner.cs" /> 94 94 <Compile Include="LayerCreator.cs" /> 95 <Compile Include="LayerUniformSubScopesProcessor.cs" /> 95 96 <Compile Include="LayerUpdator.cs" /> 96 97 <Compile Include="MatingPoolCreator.cs" /> 98 <Compile Include="NumberOfSelectedSubScopesCalculator.cs" /> 97 99 <Compile Include="OpenNewLayerCalculator.cs" /> 98 100 <Compile Include="MergingReducerCalculator.cs" /> -
branches/ALPS/HeuristicLab.Operators/3.3/UniformSubScopesProcessor.cs
r12018 r12035 34 34 [Item("UniformSubScopesProcessor", "An operator which applies a specified operator on all sub-scopes at the given depth of the current scope.")] 35 35 [StorableClass] 36 public sealedclass UniformSubScopesProcessor : SingleSuccessorOperator {36 public class UniformSubScopesProcessor : SingleSuccessorOperator { 37 37 private OperatorParameter OperatorParameter { 38 38 get { return (OperatorParameter)Parameters["Operator"]; } … … 59 59 60 60 [StorableConstructor] 61 pr ivateUniformSubScopesProcessor(bool deserializing) : base(deserializing) { }62 pr ivateUniformSubScopesProcessor(UniformSubScopesProcessor original, Cloner cloner)61 protected UniformSubScopesProcessor(bool deserializing) : base(deserializing) { } 62 protected UniformSubScopesProcessor(UniformSubScopesProcessor original, Cloner cloner) 63 63 : base(original, cloner) { 64 64 } … … 88 88 } 89 89 90 pr ivateIEnumerable<IScope> GetScopesOnLevel(IScope scope, int d) {90 protected IEnumerable<IScope> GetScopesOnLevel(IScope scope, int d) { 91 91 if (d == 0) yield return scope; 92 92 else {
Note: See TracChangeset
for help on using the changeset viewer.