#region License Information /* HeuristicLab * Copyright (C) 2002-2010 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.Drawing; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Operators; using HeuristicLab.Optimization.Operators; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Analysis.FitnessLandscape.Analysis { [StorableClass] public class FitnessCloudAnalyzer : AlgorithmOperator, IQualityTrailAnalyzer { public bool EnabledByDefault { get { return false; } } #region Parameters public LookupParameter QualityTrailParameter { get { return (LookupParameter)Parameters["Quality Trail"]; } } public LookupParameter FitnessCloudParameter { get { return (LookupParameter)Parameters["Fitness Cloud"]; } } public LookupParameter ResultsParameter { get { return (LookupParameter)Parameters["Results"]; } } #endregion [StorableConstructor] protected FitnessCloudAnalyzer(bool deserializing) : base(deserializing) { } protected FitnessCloudAnalyzer(FitnessCloudAnalyzer original, Cloner cloner) : base(original, cloner) { } public FitnessCloudAnalyzer() { Parameters.Add(new LookupParameter("Quality Trail", "The qualities of the solutions")); Parameters.Add(new LookupParameter("Fitness Cloud", "Information stability development over time")); Parameters.Add(new LookupParameter("Results", "The collection of all results of this algorithm")); var resultsCollector = new ResultsCollector(); resultsCollector.CollectedValues.Add(new LookupParameter(FitnessCloudParameter.Name)); OperatorGraph.InitialOperator = resultsCollector; resultsCollector.Successor = null; } public override IDeepCloneable Clone(Cloner cloner) { return new FitnessCloudAnalyzer(this, cloner); } public override IOperation Apply() { ScatterPlot fitnessCloud = FitnessCloudParameter.ActualValue; if (fitnessCloud == null) { fitnessCloud = new ScatterPlot(); FitnessCloudParameter.ActualValue = fitnessCloud; fitnessCloud.Name = "Fitness Cloud"; fitnessCloud.XAxisName = "Fitness"; fitnessCloud.YAxisName = "Neighboring Fitness"; } DataTable qualityTrail = QualityTrailParameter.ActualValue; if (qualityTrail != null && qualityTrail.Rows.Count > 0) { var qualities = qualityTrail.Rows.First().Values.ToList(); if (qualities.Count > 2) { fitnessCloud.Add(Utils.Delta(qualities, (a, b) => new PointF((float)a, (float)b))); } } return base.Apply(); } } }