[13672] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15583] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[13672] | 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 |
|
---|
[16310] | 22 | using System.Collections.Generic;
|
---|
[14044] | 23 | using System.Linq;
|
---|
[13672] | 24 | using HeuristicLab.Common;
|
---|
[13725] | 25 | using HeuristicLab.Core;
|
---|
[13672] | 26 | using HeuristicLab.Data;
|
---|
[16310] | 27 | using HeuristicLab.Operators;
|
---|
[13672] | 28 | using HeuristicLab.Optimization;
|
---|
[16310] | 29 | using HeuristicLab.Parameters;
|
---|
[13725] | 30 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[13672] | 31 |
|
---|
[16310] | 32 | namespace HeuristicLab.Analysis {
|
---|
[13725] | 33 | [StorableClass]
|
---|
[16310] | 34 | [Item("TimelineAnalyzer", "Collects the specified double values from the results and displays them as a timeline")]
|
---|
| 35 | public class TimelineAnalyzer : SingleSuccessorOperator, IAnalyzer, IMultiObjectiveOperator {
|
---|
| 36 | public bool EnabledByDefault => true;
|
---|
| 37 | public string ResultName => "Timeline";
|
---|
[14097] | 38 |
|
---|
[16310] | 39 | public IFixedValueParameter<CheckedItemList<StringValue>> CollectedSuccessMeasuresParameter =>
|
---|
| 40 | (IFixedValueParameter<CheckedItemList<StringValue>>)Parameters["CollectedSuccessMeasures"];
|
---|
| 41 |
|
---|
| 42 | public ILookupParameter<ResultCollection> ResultsParameter => (ILookupParameter<ResultCollection>)Parameters["Results"];
|
---|
| 43 |
|
---|
| 44 | public ResultParameter<DataTable> ResultParameter => (ResultParameter<DataTable>)Parameters[ResultName];
|
---|
| 45 |
|
---|
| 46 | public CheckedItemList<StringValue> CollectedSuccessMeasures => CollectedSuccessMeasuresParameter.Value;
|
---|
| 47 |
|
---|
[13725] | 48 | [StorableConstructor]
|
---|
[16310] | 49 | protected TimelineAnalyzer(bool deserializing) : base(deserializing) { }
|
---|
[13725] | 50 |
|
---|
[14097] | 51 |
|
---|
[16310] | 52 | protected TimelineAnalyzer(TimelineAnalyzer original, Cloner cloner) : base(original, cloner) { }
|
---|
[13672] | 53 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[16310] | 54 | return new TimelineAnalyzer(this, cloner);
|
---|
[13672] | 55 | }
|
---|
| 56 |
|
---|
[16310] | 57 | public TimelineAnalyzer() {
|
---|
| 58 | var names = new List<string> {
|
---|
| 59 | new CrowdingAnalyzer().ResultName,
|
---|
| 60 | new GenerationalDistanceAnalyzer().ResultName,
|
---|
| 61 | new InvertedGenerationalDistanceAnalyzer().ResultName,
|
---|
| 62 | new HypervolumeAnalyzer().ResultName,
|
---|
| 63 | new SpacingAnalyzer().ResultName
|
---|
| 64 | };
|
---|
| 65 | var analyzers = new CheckedItemList<StringValue> (names.Select(n=> new StringValue(n)));
|
---|
| 66 | Parameters.Add(new FixedValueParameter<CheckedItemList<StringValue>>("CollectedSuccessMeasures",analyzers));
|
---|
| 67 | Parameters.Add(new LookupParameter<ResultCollection>("Results"));
|
---|
| 68 | Parameters.Add(new ResultParameter<DataTable>("Timeline", "The development of the success measures over the generations","Results", new DataTable("Timeline","")));
|
---|
[14097] | 69 | }
|
---|
[14044] | 70 |
|
---|
| 71 | public override IOperation Apply() {
|
---|
[16310] | 72 | if (ResultParameter.ActualValue == null) ResultParameter.ActualValue = new DataTable(ResultName,"");
|
---|
| 73 | var plot = ResultParameter.ActualValue;
|
---|
| 74 | var resultCollection = ResultsParameter.ActualValue;
|
---|
| 75 | foreach (var resultName in CollectedSuccessMeasures.CheckedItems.Select(i=>i.Value.Value)) {
|
---|
| 76 | if(!resultCollection.ContainsKey(resultName)) continue;
|
---|
| 77 | if(!(resultCollection[resultName].Value is DoubleValue res)) continue;
|
---|
| 78 | if(!plot.Rows.ContainsKey(resultName)) plot.Rows.Add(new DataRow(resultName));
|
---|
| 79 | plot.Rows[resultName].Values.Add(res.Value);
|
---|
| 80 | }
|
---|
[14044] | 81 | return base.Apply();
|
---|
[13672] | 82 | }
|
---|
| 83 | }
|
---|
| 84 | }
|
---|