Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12159 for branches/ALPS


Ignore:
Timestamp:
03/09/15 10:32:47 (10 years ago)
Author:
pfleck
Message:

#2350

  • Changed the SteadyStateMatingPoolCreator to put the mating pool in the working scope.
  • Added the ScopeIndexAssigner for setting the correct layer number.
  • Adapted the AlpsSsGeneticAlgorithmMainLoop.
Location:
branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3
Files:
1 added
5 edited

Legend:

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

    r12157 r12159  
    135135      var layerProcessor = new /*Layer*/UniformSubScopesProcessor();
    136136      var layerVariableCreator = new VariableCreator() { Name = "Initialize Layer" };
     137      var layerNumberCreator = new ScopeIndexAssigner() { Name = "Create Layer Number" };
    137138      var layerSolutionsCreator = new SolutionsCreator();
    138139      var initializeAgeProcessor = new UniformSubScopesProcessor();
     
    154155      layersProcessor.TargetScopeParameter.ActualName = "Layers";
    155156      layersProcessor.Operator = layerCreator;
     157      layersProcessor.Successor = initializeEvaluatedSolutions;
    156158
    157159      layerCreator.NumberOfSubScopesParameter.ActualName = "NumberOfLayers";
     
    160162
    161163      layerProcessor.Operator = layerVariableCreator;
    162       layerProcessor.Successor = initializeEvaluatedSolutions;
    163164
    164165      layerVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("LayerResults"));
    165       layerVariableCreator.Successor = layerSolutionsCreator;
     166      layerVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Layer"));
     167      layerVariableCreator.Successor = layerNumberCreator;
     168
     169      layerNumberCreator.ValueParameter.ActualName = "Layer";
     170      layerNumberCreator.Successor = layerSolutionsCreator;
    166171
    167172      layerSolutionsCreator.NumberOfSolutionsParameter.ActualName = LayerSizeParameter.Name;
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsGeneticAlgorithmMainLoop.cs

    r12150 r12159  
    7171
    7272      var variableCreator = new VariableCreator() { Name = "Initialize" };
     73      var layersProcessor = new NamedSubScopeProcessor() { Name = "Process Layers" };
    7374      var randomScopeProcessor = new RandomLayerProcessor() { Name = "Select a layer" };
    74       var layerPopulationSizeCounter = new SubScopesCounter() { Name = "Count LayerPopulationSize" };
    7575      var isLayerZeroComperator = new Comparator() { Name = "IsLayerZero = Layer == 0" };
    7676      var isLayerZeroBranch = new ConditionalBranch() { Name = "IsLayerZero?" };
     
    8585      var initializeAge = new Assigner() { Name = "Initialize Age" };
    8686      var selectRandomTargetIndex = new RandomIntAssigner();
    87       var copyLayer = new BestSelector();
    88       var copyLayerProcessor = new SubScopesProcessor();
    8987      var matingPoolCreator = new SteadyStateMatingPoolCreator() { Name = "Create MatingPool" };
     88      var matingPoolProcessor = new NamedSubScopeProcessor() { Name = "Process MatingPool" };
    9089      var matingPoolSize = new SubScopesCounter() { Name = "MatingPoolSize" };
    9190      var matingPoolSizeMin2 = new Comparator() { Name = "ValidParents = MatingPoolSize >= 2" };
     
    116115      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("MatingPoolSize", new IntValue(0)));
    117116      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("ValidParents", new BoolValue(false)));
    118       variableCreator.Successor = randomScopeProcessor;
    119 
    120       randomScopeProcessor.Operator = layerPopulationSizeCounter;
     117      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("IsLayerZero", new BoolValue(false)));
     118      variableCreator.Successor = layersProcessor;
     119
     120      layersProcessor.Operator = randomScopeProcessor;
     121      layersProcessor.TargetScopeParameter.ActualName = "Layers";
     122
     123      randomScopeProcessor.Operator = isLayerZeroComperator;
    121124      randomScopeProcessor.Successor = incrIterations;
    122 
    123       layerPopulationSizeCounter.ValueParameter.ActualName = "LayerPopulationSize";
    124       layerPopulationSizeCounter.AccumulateParameter.Value =  new BoolValue(false);
    125       layerPopulationSizeCounter.Successor = isLayerZeroComperator;
    126125
    127126      isLayerZeroComperator.LeftSideParameter.ActualName = "Layer";
     
    171170      selectRandomTargetIndex.LeftSideParameter.ActualName = "TargetIndex";
    172171      selectRandomTargetIndex.MinimumParameter.Value = new IntValue(0);
    173       selectRandomTargetIndex.MaximumParameter.ActualName = "LayerPopulationSize";
     172      selectRandomTargetIndex.MaximumParameter.ActualName = "LayerSize";
    174173      selectRandomTargetIndex.MaximumParameter.Value = null;
    175       selectRandomTargetIndex.Successor = copyLayer;
    176 
    177       copyLayer.NumberOfSelectedSubScopesParameter.ActualName = "LayerPopulationSize";
    178       copyLayer.CopySelected = new BoolValue(true);
    179       copyLayer.Successor = copyLayerProcessor;
    180 
    181       copyLayerProcessor.Operators.Add(new EmptyOperator());
    182       copyLayerProcessor.Operators.Add(matingPoolCreator);
    183 
    184       matingPoolCreator.Successor = matingPoolSize;
     174      selectRandomTargetIndex.Successor = matingPoolCreator;
     175
     176      matingPoolCreator.Successor = matingPoolProcessor;
     177
     178      matingPoolProcessor.Operator = matingPoolSize;
     179      matingPoolProcessor.TargetScopeParameter.ActualName = "WorkingScope";
    185180
    186181      matingPoolSize.ValueParameter.ActualName = "MatingPoolSize";
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/HeuristicLab.Algorithms.ALPS.SteadyState-3.3.csproj

    r12157 r12159  
    144144    <Compile Include="RandomIntAssigner.cs" />
    145145    <Compile Include="RandomLayerProcessor.cs" />
     146    <Compile Include="ScopeIndexAssigner.cs" />
    146147    <Compile Include="SteadyStateMatingPoolCreator.cs" />
    147148  </ItemGroup>
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/NamedSubScopeProcessor.cs

    r12157 r12159  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.Operators;
    2625using HeuristicLab.Parameters;
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/SteadyStateMatingPoolCreator.cs

    r12136 r12159  
    3232  [StorableClass]
    3333  public class SteadyStateMatingPoolCreator : SingleSuccessorOperator {
     34    private ILookupParameter<IScope> WorkingScopeParameter {
     35      get { return (ILookupParameter<IScope>)Parameters["WorkingScope"]; }
     36    }
     37    private ILookupParameter<IntValue> LayerParameter {
     38      get { return (ILookupParameter<IntValue>)Parameters["Layer"]; }
     39    }
    3440
    3541    [StorableConstructor]
     
    4349    public SteadyStateMatingPoolCreator()
    4450      : base() {
     51      Parameters.Add(new LookupParameter<IScope>("WorkingScope"));
     52      Parameters.Add(new LookupParameter<IntValue>("Layer"));
    4553    }
    4654
    4755    public override IOperation Apply() {
    48       var matingPool = ExecutionContext.Scope;
    49       var currentLayer = matingPool.Parent;
    50       int layerNumber = ((IntValue)currentLayer.Variables["Layer"].Value).Value;
     56      int layerNumber = LayerParameter.ActualValue.Value;
     57      var workingScope = WorkingScopeParameter.ActualValue;
     58
     59      var currentLayer = ExecutionContext.Scope;
     60      foreach (var individual in currentLayer.SubScopes) {
     61        workingScope.SubScopes.Add((IScope)individual.Clone());
     62      }
    5163
    5264      if (layerNumber > 0) {
    53         var prevLayer = currentLayer.Parent.SubScopes[layerNumber - 1];
    54         var prevLayerIndividuals = prevLayer.SubScopes;
     65        var layers = currentLayer.Parent;
     66        var prevLayer = layers.SubScopes[layerNumber - 1];
    5567
    56         foreach (var individual in prevLayerIndividuals) {
    57           matingPool.SubScopes.Add((IScope)individual.Clone());
     68        foreach (var individual in prevLayer.SubScopes) {
     69          workingScope.SubScopes.Add((IScope)individual.Clone());
    5870        }
    5971      }
Note: See TracChangeset for help on using the changeset viewer.