Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/Analyzers/EvaluatedSolutionsHistoryAnalyzer.cs @ 12863

Last change on this file since 12863 was 12863, checked in by pfleck, 9 years ago

#2269: Added EvaluatedSolutionsHistoryAnalyzer to keep track of the number of evaluated solutions when the analyzers are called.

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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
22using HeuristicLab.Analysis;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Operators;
27using HeuristicLab.Optimization;
28using HeuristicLab.Optimization.Operators;
29using HeuristicLab.Parameters;
30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
31
32namespace HeuristicLab.Algorithms.ALPS {
33  [Item("EvaluatedSolutionsHistoryAnalyzer", "")]
34  [StorableClass]
35  public sealed class EvaluatedSolutionsHistoryAnalyzer : AlgorithmOperator, IAnalyzer {
36    #region Parameter Properties
37    public ILookupParameter<IntValue> EvaluatedSolutionsParameter {
38      get { return (ILookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
39    }
40    public ILookupParameter<DataTable> EvaluatedSolutionsHistoryParameter {
41      get { return (ILookupParameter<DataTable>)Parameters["EvaluatedSolutionsHistory"]; }
42    }
43    public ValueLookupParameter<ResultCollection> ResultsParameter {
44      get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
45    }
46    #endregion
47
48    public bool EnabledByDefault { get { return false; } }
49
50    [StorableConstructor]
51    private EvaluatedSolutionsHistoryAnalyzer(bool deserializing)
52      : base(deserializing) { }
53    private EvaluatedSolutionsHistoryAnalyzer(EvaluatedSolutionsHistoryAnalyzer original, Cloner cloner)
54      : base(original, cloner) { }
55    public override IDeepCloneable Clone(Cloner cloner) {
56      return new EvaluatedSolutionsHistoryAnalyzer(this, cloner);
57    }
58    public EvaluatedSolutionsHistoryAnalyzer()
59      : base() {
60      #region Create parameters
61      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", ""));
62      Parameters.Add(new ValueLookupParameter<DataTable>("EvaluatedSolutionsHistory"));
63      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection where the analysis values should be stored."));
64      #endregion
65
66      #region Create operators
67      DataTableValuesCollector dataTableValuesCollector = new DataTableValuesCollector();
68      ResultsCollector resultsCollector = new ResultsCollector();
69
70      dataTableValuesCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions", null, EvaluatedSolutionsParameter.Name));
71      dataTableValuesCollector.DataTableParameter.ActualName = EvaluatedSolutionsHistoryParameter.Name;
72
73      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>(EvaluatedSolutionsHistoryParameter.Name));
74      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
75      #endregion
76
77      #region Create operator graph
78      OperatorGraph.InitialOperator = dataTableValuesCollector;
79      dataTableValuesCollector.Successor = resultsCollector;
80      resultsCollector.Successor = null;
81      #endregion
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.