[7128] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 | using System.Drawing;
|
---|
| 22 | using System.Linq;
|
---|
| 23 | using HeuristicLab.Common;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Operators;
|
---|
| 26 | using HeuristicLab.Optimization.Operators;
|
---|
| 27 | using HeuristicLab.Parameters;
|
---|
[16573] | 28 | using HEAL.Attic;
|
---|
[7128] | 29 |
|
---|
| 30 | namespace HeuristicLab.Analysis.FitnessLandscape.Analysis {
|
---|
| 31 |
|
---|
[16573] | 32 | [StorableType("4156976F-4E61-48BA-B598-FEA872F2E948")]
|
---|
[7128] | 33 | public class FitnessCloudAnalyzer : AlgorithmOperator, IQualityTrailAnalyzer {
|
---|
[7176] | 34 | public bool EnabledByDefault {
|
---|
| 35 | get { return false; }
|
---|
| 36 | }
|
---|
[7128] | 37 |
|
---|
| 38 | #region Parameters
|
---|
| 39 | public LookupParameter<DataTable> QualityTrailParameter {
|
---|
| 40 | get { return (LookupParameter<DataTable>)Parameters["Quality Trail"]; }
|
---|
| 41 | }
|
---|
| 42 | public LookupParameter<ScatterPlot> FitnessCloudParameter {
|
---|
| 43 | get { return (LookupParameter<ScatterPlot>)Parameters["Fitness Cloud"]; }
|
---|
| 44 | }
|
---|
| 45 | public LookupParameter<VariableCollection> ResultsParameter {
|
---|
| 46 | get { return (LookupParameter<VariableCollection>)Parameters["Results"]; }
|
---|
| 47 | }
|
---|
| 48 | #endregion
|
---|
| 49 |
|
---|
| 50 | [StorableConstructor]
|
---|
[16573] | 51 | protected FitnessCloudAnalyzer(StorableConstructorFlag _) : base(_) { }
|
---|
[7128] | 52 | protected FitnessCloudAnalyzer(FitnessCloudAnalyzer original, Cloner cloner) : base(original, cloner) { }
|
---|
| 53 |
|
---|
| 54 | public FitnessCloudAnalyzer() {
|
---|
| 55 | Parameters.Add(new LookupParameter<DataTable>("Quality Trail", "The qualities of the solutions"));
|
---|
| 56 | Parameters.Add(new LookupParameter<ScatterPlot>("Fitness Cloud", "Information stability development over time"));
|
---|
| 57 | Parameters.Add(new LookupParameter<VariableCollection>("Results", "The collection of all results of this algorithm"));
|
---|
| 58 |
|
---|
| 59 | var resultsCollector = new ResultsCollector();
|
---|
| 60 | resultsCollector.CollectedValues.Add(new LookupParameter<ScatterPlot>(FitnessCloudParameter.Name));
|
---|
| 61 |
|
---|
| 62 | OperatorGraph.InitialOperator = resultsCollector;
|
---|
| 63 | resultsCollector.Successor = null;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 67 | return new FitnessCloudAnalyzer(this, cloner);
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | public override IOperation Apply() {
|
---|
| 71 | ScatterPlot fitnessCloud = FitnessCloudParameter.ActualValue;
|
---|
| 72 | if (fitnessCloud == null) {
|
---|
| 73 | fitnessCloud = new ScatterPlot();
|
---|
| 74 | FitnessCloudParameter.ActualValue = fitnessCloud;
|
---|
| 75 | fitnessCloud.Name = "Fitness Cloud";
|
---|
| 76 | fitnessCloud.XAxisName = "Fitness";
|
---|
| 77 | fitnessCloud.YAxisName = "Neighboring Fitness";
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | DataTable qualityTrail = QualityTrailParameter.ActualValue;
|
---|
| 81 | if (qualityTrail != null && qualityTrail.Rows.Count > 0) {
|
---|
| 82 | var qualities = qualityTrail.Rows.First().Values.ToList();
|
---|
| 83 | if (qualities.Count > 2) {
|
---|
| 84 | fitnessCloud.Add(Utils.Delta(qualities, (a, b) => new PointF((float)a, (float)b)));
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 | return base.Apply();
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
| 90 | }
|
---|