#region License Information
/* HeuristicLab
* Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using HEAL.Attic;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Optimization;
namespace HeuristicLab.Analysis.FitnessLandscape {
[Item("Random Walk Calculator", "Calculates characteristics from a random walk.")]
[StorableType("FF8080CA-5E93-4390-8184-67B92EBF5ACD")]
public sealed class RandomWalkCalculator : AlgorithmCharacteristicCalculator {
[StorableConstructor]
private RandomWalkCalculator(StorableConstructorFlag _) : base(_) { }
private RandomWalkCalculator(RandomWalkCalculator original, Cloner cloner) : base(original, cloner) { }
public RandomWalkCalculator() : this(new RandomWalk()) { }
public RandomWalkCalculator(RandomWalk walker) : base(walker) {
Name = ItemName;
Description = ItemDescription;
characteristics = new CheckedItemList(
new[] { "AutoCorrelation1", "CorrelationLength", "InformationContent",
"PartialInformationContent", "DensityBasinInformation", "InformationStability",
"Diversity", "Regularity", "TotalEntropy", "PeakInformationContent",
"PeakDensityBasinInformation" }.Select(x => new StringValue(x)));
}
public override IDeepCloneable Clone(Cloner cloner) {
return new RandomWalkCalculator(this, cloner);
}
public override bool CanCalculate() {
return base.CanCalculate() && Problem.Operators.Any(x => x is IManipulator);
}
public override IEnumerable Calculate() {
foreach (var result in base.Calculate())
yield return new Result("RandomWalk." + Algorithm.MutatorParameter.Value.Name + "." + result.Name, result.Value);
}
}
}