Changeset 15331


Ignore:
Timestamp:
08/17/17 16:05:58 (2 years ago)
Author:
abeham
Message:

#2457: added FLA Characterizer algorithm

Location:
branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/Algorithms/FLACharacterizer.cs

    r15325 r15331  
    2020#endregion
    2121
     22using System;
     23using System.Threading;
    2224using HeuristicLab.Common;
    2325using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Selection;
    27 using System.Linq;
     27using HeuristicLab.Optimization;
     28using HeuristicLab.Parameters;
    2829
    2930namespace HeuristicLab.Analysis.FitnessLandscape {
    30   [Item("Random Walk", "A random walk applies a certain manipulation operation over and over.")]
     31  [Item("FLA Characterizer", "An algorithm that executes a characteristic calculator.")]
    3132  [StorableClass]
    32   [Creatable(CreatableAttribute.Categories.TestingAndAnalysis + CreatableAttribute.Categories.SplitToken + "1" + CreatableAttribute.Categories.OrderToken + "FLA", Priority = 301)]
    33   public sealed class RandomWalk : LocalAnalysis<RandomSelector> {
     33  [Creatable(CreatableAttribute.Categories.TestingAndAnalysis + CreatableAttribute.Categories.SplitToken + "1" + CreatableAttribute.Categories.OrderToken + "FLA", Priority = 300)]
     34  public sealed class FLACharacterizer : BasicAlgorithm {
     35    public override bool SupportsPause { get { return false; } }
     36   
     37    public IValueParameter<ICharacteristicCalculator> CalculatorParameter {
     38      get { return (IValueParameter<ICharacteristicCalculator>)Parameters["Calculator"]; }
     39    }
    3440
    3541    [StorableConstructor]
    36     private RandomWalk(bool deserializing) : base(deserializing) { }
    37     private RandomWalk(RandomWalk original, Cloner cloner) : base(original, cloner) { }
    38     public RandomWalk()
    39       : base(new RandomSelector()) {
    40       SelectorParameter.Value.NumberOfSelectedSubScopesParameter.Hidden = true;
    41       MainLoop.SampleSizeParameter.Value = new IntValue(1);
    42       var trailAnalyzer = AnalyzerParameter.Value.Operators.OfType<QualityTrailMultiAnalyzer>().Single();
    43       var upDown = trailAnalyzer.Operators.OfType<UpDownWalkAnalyzer>().Single();
    44       trailAnalyzer.Operators.SetItemCheckedState(upDown, false);
     42    private FLACharacterizer(bool deserializing) : base(deserializing) { }
     43    private FLACharacterizer(FLACharacterizer original, Cloner cloner) : base(original, cloner) { }
     44    public FLACharacterizer() : base() {
     45      Parameters.Add(new ValueParameter<ICharacteristicCalculator>("Calculator", "The FLA characteristic calculator.", new RandomWalkCalculator()));
    4546    }
    4647
    4748    public override IDeepCloneable Clone(Cloner cloner) {
    48       return new RandomWalk(this, cloner);
     49      return new FLACharacterizer(this, cloner);
     50    }
     51
     52    protected override void Run(CancellationToken cancellationToken) {
     53      var calculator = CalculatorParameter.Value;
     54      calculator.Problem = Problem;
     55      if (calculator.CanCalculate()) {
     56        foreach (var result in calculator.Calculate()) {
     57          Results.Add(result);
     58        }
     59      } else throw new InvalidOperationException("Calculator cannot be applied.");
    4960    }
    5061  }
  • branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/HeuristicLab.Analysis.FitnessLandscape-3.3.csproj

    r14691 r15331  
    189189  <ItemGroup>
    190190    <Compile Include="Algorithms\AdaptiveWalk.cs" />
     191    <Compile Include="Algorithms\FLACharacterizer.cs" />
    191192    <Compile Include="Algorithms\UpDownWalk.cs" />
    192193    <Compile Include="Algorithms\RandomWalk.cs" />
Note: See TracChangeset for help on using the changeset viewer.