Free cookie consent management tool by TermsFeed Policy Generator

source: branches/1614_GeneralizedQAP/HeuristicLab.Analysis.FitnessLandscape/3.3/Analysis/FitnessCloudAnalyzer.cs @ 16728

Last change on this file since 16728 was 16728, checked in by abeham, 6 years ago

#1614: updated to new persistence and .NET 4.6.1

File size: 3.6 KB
RevLine 
[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
[13583]21
[7128]22using System.Drawing;
23using System.Linq;
[16728]24using HEAL.Attic;
[7128]25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Operators;
28using HeuristicLab.Optimization.Operators;
29using HeuristicLab.Parameters;
30
[13583]31namespace HeuristicLab.Analysis.FitnessLandscape {
[7128]32
[16728]33  [StorableType("201F8E4F-601F-42EC-8E75-2ED240240BE5")]
[7128]34  public class FitnessCloudAnalyzer : AlgorithmOperator, IQualityTrailAnalyzer {
[7176]35    public bool EnabledByDefault {
36      get { return false; }
37    }
[7128]38
39    #region Parameters
40    public LookupParameter<DataTable> QualityTrailParameter {
41      get { return (LookupParameter<DataTable>)Parameters["Quality Trail"]; }
42    }
43    public LookupParameter<ScatterPlot> FitnessCloudParameter {
44      get { return (LookupParameter<ScatterPlot>)Parameters["Fitness Cloud"]; }
45    }
46    public LookupParameter<VariableCollection> ResultsParameter {
47      get { return (LookupParameter<VariableCollection>)Parameters["Results"]; }
48    }
49    #endregion
50
51    [StorableConstructor]
[16728]52    protected FitnessCloudAnalyzer(StorableConstructorFlag _) : base(_) { }
[7128]53    protected FitnessCloudAnalyzer(FitnessCloudAnalyzer original, Cloner cloner) : base(original, cloner) { }
54
55    public FitnessCloudAnalyzer() {
56      Parameters.Add(new LookupParameter<DataTable>("Quality Trail", "The qualities of the solutions"));
57      Parameters.Add(new LookupParameter<ScatterPlot>("Fitness Cloud", "Information stability development over time"));
58      Parameters.Add(new LookupParameter<VariableCollection>("Results", "The collection of all results of this algorithm"));
59
60      var resultsCollector = new ResultsCollector();
61      resultsCollector.CollectedValues.Add(new LookupParameter<ScatterPlot>(FitnessCloudParameter.Name));
62
63      OperatorGraph.InitialOperator = resultsCollector;
64      resultsCollector.Successor = null;
65    }
66
67    public override IDeepCloneable Clone(Cloner cloner) {
68      return new FitnessCloudAnalyzer(this, cloner);
69    }
70
71    public override IOperation Apply() {
72      ScatterPlot fitnessCloud = FitnessCloudParameter.ActualValue;
73      if (fitnessCloud == null) {
74        fitnessCloud = new ScatterPlot();
75        FitnessCloudParameter.ActualValue = fitnessCloud;
76        fitnessCloud.Name = "Fitness Cloud";
77        fitnessCloud.XAxisName = "Fitness";
78        fitnessCloud.YAxisName = "Neighboring Fitness";
79      }
80
81      DataTable qualityTrail = QualityTrailParameter.ActualValue;
82      if (qualityTrail != null && qualityTrail.Rows.Count > 0) {
83        var qualities = qualityTrail.Rows.First().Values.ToList();
84        if (qualities.Count > 2) {
85          fitnessCloud.Add(Utils.Delta(qualities, (a, b) => new PointF((float)a, (float)b)));
86        }
87      }
88      return base.Apply();
89    }
90  }
91}
Note: See TracBrowser for help on using the repository browser.