Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17854


Ignore:
Timestamp:
03/01/21 18:09:17 (4 years ago)
Author:
pfleck
Message:

#3107 Added a new operator hook for ALPS for adapting the reinitialization strategy.

Location:
branches/3107_LearningALPS
Files:
2 added
4 edited

Legend:

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

    r17198 r17854  
    121121      get { return (IValueParameter<MultiTerminator>)Parameters["Terminator"]; }
    122122    }
     123
     124    private IConstrainedValueParameter<IReinitializationStrategyController> ReinitializationStrategyParameter {
     125      get { return (IConstrainedValueParameter<IReinitializationStrategyController>)Parameters["ReinitializationStrategy"]; }
     126    }
    123127    #endregion
    124128
     
    207211      get { return generationsTerminator.Threshold.Value; }
    208212      set { generationsTerminator.Threshold.Value = value; }
     213    }
     214
     215    public IReinitializationStrategyController ReinitializationStrategy {
     216      get { return ReinitializationStrategyParameter.Value; }
     217      set { ReinitializationStrategyParameter.Value = value; }
    209218    }
    210219    #endregion
     
    312321
    313322      Parameters.Add(new ValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator()));
     323
     324      Parameters.Add(new OptionalConstrainedValueParameter<IReinitializationStrategyController>("ReinitializationStrategy", "An optional strategy adaption when reseeding the lowest layer."));
    314325      #endregion
    315326
     
    406417      #endregion
    407418
     419      #region Set strategy adaption
     420      foreach (var adaptor in ApplicationManager.Manager.GetInstances<IReinitializationStrategyController>().OrderBy(o => o.Name))
     421        ReinitializationStrategyParameter.ValidValues.Add(adaptor);
     422      #endregion
     423
    408424      #region Create analyzers
    409425      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
  • branches/3107_LearningALPS/HeuristicLab.Algorithms.ALPS/3.3/ReseedingController.cs

    r17180 r17854  
    2020#endregion
    2121
     22using System;
     23using System.Linq;
    2224using HeuristicLab.Common;
    2325using HeuristicLab.Core;
     
    3436      get { return (ILookupParameter<IntValue>)Parameters["Generations"]; }
    3537    }
     38
    3639    public ILookupParameter<IntValue> AgeGapParameter {
    3740      get { return (ILookupParameter<IntValue>)Parameters["AgeGap"]; }
    3841    }
     42
    3943    public OperatorParameter FirstLayerOperatorParameter {
    4044      get { return (OperatorParameter)Parameters["FirstLayerOperator"]; }
     45    }
     46
     47    public OperatorParameter StrategyAdaptionOperatorParameter {
     48      get { return (OperatorParameter)Parameters["ReinitializationStrategyOperator"]; }
    4149    }
    4250
     
    4654    }
    4755
     56    public IOperator ReinitializationStrategyOperator {
     57      get { return StrategyAdaptionOperatorParameter.Value; }
     58      set { StrategyAdaptionOperatorParameter.Value = value; }
     59    }
     60
    4861    [StorableConstructor]
    4962    private ReseedingController(StorableConstructorFlag _) : base(_) { }
    5063
     64    [StorableHook(HookType.AfterDeserialization)]
     65    private void AfterDeserialization() {
     66      if (!Parameters.ContainsKey("ReinitializationStrategyOperator")) {
     67        Parameters.Add(new OperatorParameter("ReinitializationStrategyOperator", "The optional operator to control the strategy parameter."));
     68      }
     69    }
     70
    5171    private ReseedingController(ReseedingController original, Cloner cloner)
    52       : base(original, cloner) {
    53     }
     72      : base(original, cloner) { }
     73
    5474    public override IDeepCloneable Clone(Cloner cloner) {
    5575      return new ReseedingController(this, cloner);
     
    6181      Parameters.Add(new ValueLookupParameter<IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers."));
    6282      Parameters.Add(new OperatorParameter("FirstLayerOperator", "The operator that is performed on the first layer if reseeding is required."));
     83      Parameters.Add(new OperatorParameter("ReinitializationStrategyOperator", "The optional operator to control the strategy parameter."));
    6384    }
    6485
     
    6990      var next = new OperationCollection(base.Apply());
    7091      if (generations % ageGap == 0) {
    71         var layerZeroScope = ExecutionContext.Scope.SubScopes[0];
    72         if (FirstLayerOperator != null)
     92        if (FirstLayerOperator != null) {
     93          var layerZeroScope = ExecutionContext.Scope.SubScopes.First();
    7394          next.Insert(0, ExecutionContext.CreateChildOperation(FirstLayerOperator, layerZeroScope));
     95        }
     96
     97        // insert at index 0 => strategy adaption is scheduled before reinitialization
     98        if (ReinitializationStrategyOperator != null) {
     99          var lastLayerScope = ExecutionContext.Scope.SubScopes.Last();
     100          next.Insert(0, ExecutionContext.CreateChildOperation(ReinitializationStrategyOperator, lastLayerScope));
     101        }
    74102      }
    75103      return next;
  • branches/3107_LearningALPS/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r16658 r17854  
    156156    <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" />
    157157    <Compile Include="Interfaces\IMultiObjectiveOperator.cs" />
     158    <Compile Include="Interfaces\IReinitializationStrategyController.cs" />
    158159    <Compile Include="MultiObjective\DominationCalculator.cs" />
    159160    <Compile Include="Results\IResultParameter.cs" />
  • branches/3107_LearningALPS/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r17413 r17854  
    150150    <Compile Include="Converters\DerivativeCalculator.cs" />
    151151    <Compile Include="Converters\TreeToAutoDiffTermConverter.cs" />
     152    <Compile Include="Creators\SymbolFrequencyReinitializationStrategyController.cs" />
    152153    <Compile Include="Creators\SymbolicDataAnalysisExpressionBalancedTreeCreator.cs" />
    153154    <Compile Include="Crossovers\SymbolicDataAnalysisExpressionDiversityPreservingCrossover.cs" />
Note: See TracChangeset for help on using the changeset viewer.