Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11590


Ignore:
Timestamp:
11/26/14 17:22:19 (10 years ago)
Author:
pfleck
Message:

#2269

  • Finished implementing LayerUpdator.
  • Proper implemented per-layer results.
  • Some bugfixes and wiring.
  • Added LastSubScopeCloner. Note that the First/LastSubScopeCloner/Processor might be dropped and Left/Right-Selectors are used instead. Thanks to jkarder for this suggestion.
Location:
branches/ALPS
Files:
1 added
9 edited

Legend:

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

    r11586 r11590  
    183183      get { return OperatorGraph.Iterate().OfType<SolutionsCreator>().First(); }
    184184    }
    185 
    186185    private AlpsGeneticAlgorithmMainLoop MainLoop {
    187186      get { return OperatorGraph.Iterate().OfType<AlpsGeneticAlgorithmMainLoop>().First(); }
     
    255254
    256255      layerVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Layer", new IntValue(0)));
     256      layerVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("Results", new ResultCollection()));
    257257      layerVariableCreator.Successor = layerSolutionsCreator;
    258258
     
    266266      initializeAge.Successor = null;
    267267
    268       initializeLocalEvaluatedSolutions.ValueParameter.ActualName = "EvaluatedSolutions";
     268      initializeLocalEvaluatedSolutions.ValueParameter.ActualName = "LayerEvaluatedSolutions";
    269269      initializeLocalEvaluatedSolutions.Successor = null;
    270270
    271271      initializeGlobalEvaluatedSolutions.ReductionOperation.Value.Value = ReductionOperations.Sum;
    272272      initializeGlobalEvaluatedSolutions.TargetOperation.Value.Value = ReductionOperations.Assign;
    273       initializeGlobalEvaluatedSolutions.ParameterToReduce.ActualName = "EvaluatedSolutions";
     273      initializeGlobalEvaluatedSolutions.ParameterToReduce.ActualName = "LayerEvaluatedSolutions";
    274274      initializeGlobalEvaluatedSolutions.TargetParameter.ActualName = "EvaluatedSolutions";
    275275      initializeGlobalEvaluatedSolutions.Successor = resultsCollector;
     
    373373      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    374374      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
    375       MainLoop.EldersEmigrator.SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
    376       MainLoop.EldersEmigrator.SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
     375      MainLoop.LayerUpdator.SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
     376      MainLoop.LayerUpdator.SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
    377377
    378378    }
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/AlpsGeneticAlgorithmMainLoop.cs

    r11586 r11590  
    5555      get { return OperatorGraph.Iterate().OfType<EldersEmigrator>().First(); }
    5656    }
     57    public LayerUpdator LayerUpdator {
     58      get { return OperatorGraph.Iterate().OfType<LayerUpdator>().First(); }
     59    }
    5760
    5861    [StorableConstructor]
     
    7477      var initAnalyzerPlaceholder = new Placeholder() { Name = "Analyzer (Placeholder)" };
    7578      var initLayerAnalyzerProcessor = new SubScopesProcessor();
     79      var layerVariableCreator = new VariableCreator() { Name = "Initialize Layer" };
    7680      var initLayerAnalyzerPlaceholder = new Placeholder() { Name = "LayerAnalyzer (Placeholder)" };
    7781      var matingPoolCreator = new MatingPoolCreator() { Name = "Create Mating Pools" };
    7882      var matingPoolProcessor = new UniformSubScopesProcessor();
     83      var initializeLayer = new Assigner() { Name = "Reset LayerEvaluatedSolutions" };
    7984      var mainOperator = CreatePreparedGeneticAlgorithmMainLoop();
    8085      var layerAnalyzerPlaceholder = new Placeholder() { Name = "LayerAnalyzer (Placeholder)" };
     
    101106      initAnalyzerPlaceholder.Successor = initLayerAnalyzerProcessor;
    102107
    103       initLayerAnalyzerProcessor.Operators.Add(initLayerAnalyzerPlaceholder);
     108      initLayerAnalyzerProcessor.Operators.Add(layerVariableCreator);
    104109      initLayerAnalyzerProcessor.Successor = matingPoolCreator;
     110
     111      layerVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("LayerEvaluatedSolutions"));
     112      layerVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("Results"));
     113      layerVariableCreator.Successor = initLayerAnalyzerPlaceholder;
    105114
    106115      initLayerAnalyzerPlaceholder.OperatorParameter.ActualName = LayerAnalyzerParameter.Name;
     
    110119
    111120      matingPoolProcessor.Parallel.Value = true;
    112       matingPoolProcessor.Operator = mainOperator;
     121      matingPoolProcessor.Operator = initializeLayer;
    113122      matingPoolProcessor.Successor = generationsIcrementor;
     123
     124      initializeLayer.LeftSideParameter.ActualName = "LayerEvaluatedSolutions";
     125      initializeLayer.RightSideParameter.Value = new IntValue(0);
     126      initializeLayer.Successor = mainOperator;
    114127
    115128      generationsIcrementor.ValueParameter.ActualName = "Generations";
     
    149162      var selector = mainLoop.OperatorGraph.Iterate().OfType<Placeholder>().First(o => o.OperatorParameter.ActualName == "Selector");
    150163      var crossover = mainLoop.OperatorGraph.Iterate().OfType<Placeholder>().First(o => o.OperatorParameter.ActualName == "Crossover");
     164      var subScopesCounter = mainLoop.OperatorGraph.Iterate().OfType<SubScopesCounter>().First();
    151165      var elitesMerger = mainLoop.OperatorGraph.Iterate().OfType<MergingReducer>().First();
    152166
     
    164178      ageCalculator.Successor = crossoverSuccessor;
    165179
     180      // When counting the evaluated solutions, write in LayerEvaluatedSolutions
     181      subScopesCounter.ValueParameter.ActualName = "LayerEvaluatedSolutions";
     182      subScopesCounter.AccumulateParameter.Value = new BoolValue(false);
     183
    166184      // Instead of generational loop after merging of elites, increment ages of all individuals
    167185      var processor = new UniformSubScopesProcessor();
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/EldersEmigrator.cs

    r11586 r11590  
    2020#endregion
    2121
    22 using System.Linq;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
    2524using HeuristicLab.Data;
    2625using HeuristicLab.Operators;
    27 using HeuristicLab.Optimization.Operators;
    2826using HeuristicLab.Parameters;
    2927using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4038    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
    4139      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    42     }
    43 
    44     public SolutionsCreator SolutionsCreator {
    45       get { return OperatorGraph.Iterate().OfType<SolutionsCreator>().First(); }
    4640    }
    4741
     
    7771      selectorProsessor.Successor = shiftToRightMigrator;
    7872
     73      eldersSelector.CopySelected = new BoolValue(false);
    7974      eldersSelector.Successor = null;
    8075
     
    9994      bestSelector.QualityParameter.ActualName = QualityParameter.Name;
    10095      bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
     96      bestSelector.CopySelected = new BoolValue(false);
    10197      bestSelector.Successor = rightReducer;
    10298
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/HeuristicLab.Algorithms.ALPS-3.3.csproj

    r11586 r11590  
    8383    <Compile Include="EldersEmigrator.cs" />
    8484    <Compile Include="EldersSelector.cs" />
     85    <Compile Include="LastSubScopeCloner.cs" />
    8586    <Compile Include="LayerUpdator.cs" />
    8687    <Compile Include="MatingPoolCreator.cs" />
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/LayerUpdator.cs

    r11586 r11590  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.Data;
    2526using HeuristicLab.Operators;
     27using HeuristicLab.Optimization;
    2628using HeuristicLab.Optimization.Operators;
    2729using HeuristicLab.Parameters;
     
    3234  [StorableClass]
    3335  public class LayerUpdator : AlgorithmOperator {
     36
     37    public SolutionsCreator SolutionsCreator {
     38      get { return OperatorGraph.Iterate().OfType<SolutionsCreator>().First(); }
     39    }
    3440
    3541    [StorableConstructor]
     
    5056      var openNewLayerCalculator = new OpenNewLayerCalculator();
    5157      var openNewLayerBranch = new ConditionalBranch() { Name = "OpenNewLayer?" };
     58      var layerCloner = new LastSubScopeCloner() { Name = "Copy Lower Layer" };
    5259      var incrOpenLayers = new IntCounter() { Name = "Incr. OpenLayers" };
    53       var layerScopeCreator = new SubScopesCreator();
    5460      var newLayerProsessor = new LastSubScopeProcessor();
    55       var localRandomCreator = new LocalRandomCreator();
    56       var layerVariableCreator = new Assigner() { Name = "Init Layer" };
    57       var copyPrevSubScope = new CombinedOperator() { Name = "Copy lower layer" };
    58       //var mainOperator = new CombinedOperator() { Name = "Create Offsprings" };
     61      var layerInitializer = new Assigner() { Name = "Init Layer" };
     62      var incrEvaluatedSolutionsForNewLayer = new SubScopesCounter() { Name = "Update EvaluatedSolutions" };
     63      var newResultCollectionAssigner = new Assigner() { Name = "Empty Results" };
    5964      var regenerateLayerZeroProsessor = new FirstSubScopeProcessor();
    6065      var subScopesRemover = new SubScopesRemover();
     
    6267      var initializeAgeProsessor = new UniformSubScopesProcessor();
    6368      var initializeAge = new VariableCreator() { Name = "Initialize Age" };
    64       var incrEvaluatedSolutions = new SubScopesCounter() { Name = "Update EvaluatedSolutions" };
     69      var incrEvaluatedSolutionsAfterReseeding = new SubScopesCounter() { Name = "Update EvaluatedSolutions" };
    6570      var resetGenSlr = new Assigner() { Name = "Reset GenerationsSinceLastRefresh" };
    6671
     
    7782      genSlrEqAgeGap.Successor = updateLayersBranch;
    7883
    79       updateLayersBranch.ConditionParameter.ActualName = "Updatelayers";
     84      updateLayersBranch.ConditionParameter.ActualName = "UpdateLayers";
    8085      updateLayersBranch.TrueBranch = openNewLayerCalculator;
    8186
     
    8994
    9095      openNewLayerBranch.ConditionParameter.ActualName = "OpenNewLayer";
    91       openNewLayerBranch.TrueBranch = incrOpenLayers;
     96      openNewLayerBranch.TrueBranch = layerCloner;
    9297      openNewLayerBranch.Successor = regenerateLayerZeroProsessor;
     98
     99      layerCloner.Successor = newLayerProsessor;
     100
     101      newLayerProsessor.Operator = layerInitializer;
     102      newLayerProsessor.Successor = incrOpenLayers;
     103
     104      layerInitializer.LeftSideParameter.ActualName = "Layer";
     105      layerInitializer.RightSideParameter.ActualName = "OpenLayers";
     106      layerInitializer.Successor = incrEvaluatedSolutionsForNewLayer;
     107
     108      incrEvaluatedSolutionsForNewLayer.ValueParameter.ActualName = "EvaluatedSolutions";
     109      incrEvaluatedSolutionsForNewLayer.AccumulateParameter.Value = new BoolValue(true);
     110      incrEvaluatedSolutionsForNewLayer.Successor = newResultCollectionAssigner;
     111
     112      newResultCollectionAssigner.LeftSideParameter.ActualName = "Results";
     113      newResultCollectionAssigner.RightSideParameter.Value = new ResultCollection();
     114      newResultCollectionAssigner.Successor = mainOperator;
     115      // TODO mainOperator increment age
    93116
    94117      incrOpenLayers.ValueParameter.ActualName = "OpenLayers";
    95118      incrOpenLayers.Increment = new IntValue(1);
    96       incrOpenLayers.Successor = layerScopeCreator;
    97 
    98       layerScopeCreator.NumberOfSubScopesParameter.Value = new IntValue(1);
    99       layerScopeCreator.Successor = newLayerProsessor;
    100 
    101       newLayerProsessor.Operator = localRandomCreator;
    102 
    103       localRandomCreator.Successor = layerVariableCreator;
    104 
    105       layerVariableCreator.LeftSideParameter.ActualName = "Layer";
    106       layerVariableCreator.RightSideParameter.ActualName = "Layer";
    107       layerVariableCreator.Successor = copyPrevSubScope;
    108 
    109       copyPrevSubScope.Successor = mainOperator;
     119      incrOpenLayers.Successor = null;
    110120
    111121      regenerateLayerZeroProsessor.Operator = subScopesRemover;
     
    117127
    118128      initializeAgeProsessor.Operator = initializeAge;
    119       initializeAgeProsessor.Successor = incrEvaluatedSolutions;
     129      initializeAgeProsessor.Successor = incrEvaluatedSolutionsAfterReseeding;
    120130
    121131      initializeAge.CollectedValues.Add(new ValueParameter<IntValue>("Age", new IntValue(0)));
    122132      initializeAge.Successor = null;
    123133
    124       incrEvaluatedSolutions.ValueParameter.ActualName = "EvaluatedSolutions";
    125       incrEvaluatedSolutions.Successor = null;
     134      incrEvaluatedSolutionsAfterReseeding.ValueParameter.ActualName = "EvaluatedSolutions";
     135      incrEvaluatedSolutionsAfterReseeding.AccumulateParameter.Value = new BoolValue(true);
     136      incrEvaluatedSolutionsAfterReseeding.Successor = null;
    126137
    127138      resetGenSlr.LeftSideParameter.ActualName = "GenerationsSinceLastRefresh";
  • branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/OpenNewLayerCalculator.cs

    r11586 r11590  
    4545      get { return (ILookupParameter<IntValue>)Parameters["OpenLayers"]; }
    4646    }
    47     private IValueParameter<BoolValue> OpenNewLayerParameter {
    48       get { return (IValueParameter<BoolValue>)Parameters["OpenNewLayer"]; }
     47    private ILookupParameter<BoolValue> OpenNewLayerParameter {
     48      get { return (ILookupParameter<BoolValue>)Parameters["OpenNewLayer"]; }
    4949    }
    5050
     
    6363      Parameters.Add(new LookupParameter<IntValue>("NumberOfLayers"));
    6464      Parameters.Add(new LookupParameter<IntValue>("OpenLayers"));
    65       Parameters.Add(new ValueParameter<BoolValue>("OpenNewLayer"));
     65      Parameters.Add(new LookupParameter<BoolValue>("OpenNewLayer"));
    6666    }
    6767
     
    7373      var openNewLayer = OpenNewLayerParameter;
    7474
    75       openNewLayer.Value = new BoolValue(openLayers < numberOfLayers && generations >= ageLimits[openLayers - 1]);
     75      openNewLayer.ActualValue = new BoolValue(openLayers < numberOfLayers && generations >= ageLimits[openLayers - 1]);
    7676
    7777      return base.Apply();
  • branches/ALPS/HeuristicLab.Operators/3.3/FirstSubScopeProcessor.cs

    r11586 r11590  
    2929namespace HeuristicLab.Operators {
    3030  [Item("FirstSubScopeProsessor", "An operator which applies a specified operator on the first sub-scope.")]
    31   public class FirstSubScopeProcessor : SingleSuccessorOperator {
     31  [StorableClass]
     32  public sealed class FirstSubScopeProcessor : SingleSuccessorOperator {
    3233    private OperatorParameter OperatorParameter {
    3334      get { return (OperatorParameter)Parameters["Operator"]; }
  • branches/ALPS/HeuristicLab.Operators/3.3/LastSubScopeProcessor.cs

    r11586 r11590  
    2929namespace HeuristicLab.Operators {
    3030  [Item("LastSubScopeProsessor", "An operator which applies a specified operator on the last sub-scope.")]
    31   public class LastSubScopeProcessor : SingleSuccessorOperator {
     31  [StorableClass]
     32  public sealed class LastSubScopeProcessor : SingleSuccessorOperator {
    3233    private OperatorParameter OperatorParameter {
    3334      get { return (OperatorParameter)Parameters["Operator"]; }
  • branches/ALPS/HeuristicLab.Optimization.Operators/3.3/ExpressionCalculator.cs

    r11586 r11590  
    7878predicates:
    7979  ==, <, >, isnull, not
    80 array index:
    81   []
    8280stack manipulation:
    8381  drop swap dup
Note: See TracChangeset for help on using the changeset viewer.