Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12035


Ignore:
Timestamp:
02/18/15 15:39:21 (10 years ago)
Author:
pfleck
Message:

#2269

  • Added LayerUniformSubScopesProcessor which introduces an intermediate ExecutionContext which translates array-based parameters to single-value parameters.
  • Updated ALPS-OperatorGraph to make usage of the new LayerUniformSubScopesProcessor.
  • Added a temporary operator for calculating number of selected sub scopes because presetting the value during operator parameterization does not work for the new intermediate context.

Note: the change of the PopulationSizeParameter still causes an error when creating a new layer. This will be fixed soon.

Location:
branches/ALPS
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithm.cs

    r12018 r12035  
    6969      get { return (IValueParameter<IntValue>)Parameters["NumberOfLayers"]; }
    7070    }
    71     private IValueParameter<IntValue> PopulationSizeParameter {
    72       get { return (IValueParameter<IntValue>)Parameters["PopulationSize"]; }
     71    private IValueParameter<IntArray> PopulationSizeParameter {
     72      get { return (IValueParameter<IntArray>)Parameters["PopulationSize"]; }
    7373    }
    7474    private IValueParameter<IntValue> MaximumGenerationsParameter {
     
    129129    }
    130130
    131     public IntValue PopulationSize {
     131    public IntArray PopulationSize {
    132132      get { return PopulationSizeParameter.Value; }
    133133      set { PopulationSizeParameter.Value = value; }
     
    216216      Parameters.Add(new ValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer()));
    217217      Parameters.Add(new ValueParameter<IntValue>("NumberOfLayers", "The number of layers.", new IntValue(5)));
    218       Parameters.Add(new ValueParameter<IntValue>("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 })));
    219219      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(1000)));
    220220      Parameters.Add(new ValueParameter<AgingScheme>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new AgingScheme(AgingSchemes.Polynomial)));
     
    231231      var globalRandomCreator = new RandomCreator();
    232232      var layer0Creator = new SubScopesCreator() { Name = "Create Layer Zero" };
    233       var layer0Processor = new SubScopesProcessor();
     233      var layer0Processor = new LayerUniformSubScopesProcessor();
    234234      var localRandomCreator = new LocalRandomCreator();
    235235      var layerVariableCreator = new VariableCreator();
     
    253253      layer0Creator.Successor = layer0Processor;
    254254
    255       layer0Processor.Operators.Add(localRandomCreator);
     255      layer0Processor.Operator = localRandomCreator;
    256256      layer0Processor.Successor = initializeGlobalEvaluatedSolutions;
    257257
     
    394394    private void Initialize() {
    395395      PopulationSizeParameter.ValueChanged += PopulationSizeParameter_ValueChanged;
    396       PopulationSize.ValueChanged += PopulationSize_ValueChanged;
     396      //PopulationSize.ValueChanged += PopulationSize_ValueChanged; TODO
    397397      ElitesParameter.ValueChanged += ElitesParameter_ValueChanged;
    398398      Elites.ValueChanged += Elites_ValueChanged;
     
    421421    }
    422422    private void ParameterizeSelectors() {
     423
    423424      foreach (var selector in SelectorParameter.ValidValues) {
    424425        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));
    426428        selector.NumberOfSelectedSubScopesParameter.Hidden = true;
    427429        ParameterizeStochasticOperatorForLayer(selector);
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithmMainLoop.cs

    r12018 r12035  
    8080      var resultsCollector = new ResultsCollector();
    8181      var matingPoolCreator = new MatingPoolCreator() { Name = "Create Mating Pools" };
    82       var matingPoolProcessor = new UniformSubScopesProcessor();
     82      var matingPoolProcessor = new LayerUniformSubScopesProcessor();
    8383      var initializeLayer = new Assigner() { Name = "Reset LayerEvaluatedSolutions" };
    8484      var mainOperator = CreatePreparedGeneticAlgorithmMainLoop();
     
    162162    private GeneticAlgorithmMainLoop CreatePreparedGeneticAlgorithmMainLoop() {
    163163      var mainLoop = new GeneticAlgorithmMainLoop();
     164      var numberOfSelectedSubScopesCalculator = new NumberOfSelectedSubScopesCalculator();
    164165      var selector = mainLoop.OperatorGraph.Iterate().OfType<Placeholder>().First(o => o.OperatorParameter.ActualName == "Selector");
    165166      var crossover = mainLoop.OperatorGraph.Iterate().OfType<Placeholder>().First(o => o.OperatorParameter.ActualName == "Crossover");
     
    167168      var elitesMerger = mainLoop.OperatorGraph.Iterate().OfType<MergingReducer>().First();
    168169
    169       // Operator starts with selector
    170       mainLoop.OperatorGraph.InitialOperator = selector;
     170      // Operator starts with numberOfSelectedSubScopesCalculator
     171      mainLoop.OperatorGraph.InitialOperator = numberOfSelectedSubScopesCalculator;
     172      numberOfSelectedSubScopesCalculator.Successor = selector;
    171173
    172174      // Insert AgeCalculator between crossover and its successor
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/EldersEmigrator.cs

    r12018 r12035  
    5656      var eldersSelector = new EldersSelector();
    5757      var shiftToRightMigrator = new ShiftToRightMigrator();
    58       var mergingProsessor = new UniformSubScopesProcessor();
     58      var mergingProsessor = new LayerUniformSubScopesProcessor();
    5959      var mergingReducer = new MergingReducer();
    6060      var subScopesCounter = new SubScopesCounter();
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/HeuristicLab.Algorithms.ALPS-3.3.csproj

    r11677 r12035  
    9393    <Compile Include="LastSubScopeCloner.cs" />
    9494    <Compile Include="LayerCreator.cs" />
     95    <Compile Include="LayerUniformSubScopesProcessor.cs" />
    9596    <Compile Include="LayerUpdator.cs" />
    9697    <Compile Include="MatingPoolCreator.cs" />
     98    <Compile Include="NumberOfSelectedSubScopesCalculator.cs" />
    9799    <Compile Include="OpenNewLayerCalculator.cs" />
    98100    <Compile Include="MergingReducerCalculator.cs" />
  • branches/ALPS/HeuristicLab.Operators/3.3/UniformSubScopesProcessor.cs

    r12018 r12035  
    3434  [Item("UniformSubScopesProcessor", "An operator which applies a specified operator on all sub-scopes at the given depth of the current scope.")]
    3535  [StorableClass]
    36   public sealed class UniformSubScopesProcessor : SingleSuccessorOperator {
     36  public class UniformSubScopesProcessor : SingleSuccessorOperator {
    3737    private OperatorParameter OperatorParameter {
    3838      get { return (OperatorParameter)Parameters["Operator"]; }
     
    5959
    6060    [StorableConstructor]
    61     private UniformSubScopesProcessor(bool deserializing) : base(deserializing) { }
    62     private UniformSubScopesProcessor(UniformSubScopesProcessor original, Cloner cloner)
     61    protected UniformSubScopesProcessor(bool deserializing) : base(deserializing) { }
     62    protected UniformSubScopesProcessor(UniformSubScopesProcessor original, Cloner cloner)
    6363      : base(original, cloner) {
    6464    }
     
    8888    }
    8989
    90     private IEnumerable<IScope> GetScopesOnLevel(IScope scope, int d) {
     90    protected IEnumerable<IScope> GetScopesOnLevel(IScope scope, int d) {
    9191      if (d == 0) yield return scope;
    9292      else {
Note: See TracChangeset for help on using the changeset viewer.