Changeset 15331
- Timestamp:
- 08/17/17 16:05:58 (7 years ago)
- 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 20 20 #endregion 21 21 22 using System; 23 using System.Threading; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab. Selection;27 using System.Linq;27 using HeuristicLab.Optimization; 28 using HeuristicLab.Parameters; 28 29 29 30 namespace 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.")] 31 32 [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 } 34 40 35 41 [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())); 45 46 } 46 47 47 48 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."); 49 60 } 50 61 } -
branches/PerformanceComparison/HeuristicLab.Analysis.FitnessLandscape/3.3/HeuristicLab.Analysis.FitnessLandscape-3.3.csproj
r14691 r15331 189 189 <ItemGroup> 190 190 <Compile Include="Algorithms\AdaptiveWalk.cs" /> 191 <Compile Include="Algorithms\FLACharacterizer.cs" /> 191 192 <Compile Include="Algorithms\UpDownWalk.cs" /> 192 193 <Compile Include="Algorithms\RandomWalk.cs" />
Note: See TracChangeset
for help on using the changeset viewer.