Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Analysis/3.3/ValueAnalysis/SingleValueAnalyzer.cs @ 10442

Last change on this file since 10442 was 9456, checked in by swagner, 12 years ago

Updated copyright year and added some missing license headers (#1889)

File size: 4.2 KB
RevLine 
[8016]1#region License Information
2/* HeuristicLab
[9456]3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[8016]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.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Operators;
26using HeuristicLab.Optimization;
27using HeuristicLab.Optimization.Operators;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30
31namespace HeuristicLab.Analysis {
32  /// <summary>
33  /// An operator which analyzes a value in the scope tree (current scope and parents).
34  /// </summary>
35  [Item("SingleValueAnalyzer", "An operator which analyzes a value in the scope tree (current scope and parents).")]
36  [StorableClass]
37  public sealed class SingleValueAnalyzer : AlgorithmOperator, IAnalyzer {
38    #region Parameter properties
39    public ILookupParameter<DoubleValue> ValueParameter {
40      get { return (ILookupParameter<DoubleValue>)Parameters["Value"]; }
41    }
42    public IValueLookupParameter<DataTable> ValuesParameter {
43      get { return (IValueLookupParameter<DataTable>)Parameters["Values"]; }
44    }
45    public IValueLookupParameter<VariableCollection> ResultsParameter {
46      get { return (IValueLookupParameter<VariableCollection>)Parameters["Results"]; }
47    }
48    #endregion
49
50    #region Properties
51    public bool EnabledByDefault {
52      get { return true; }
53    }
54    private DataTableValuesCollector DataTableValuesCollector {
55      get { return (DataTableValuesCollector)OperatorGraph.InitialOperator; }
56    }
57    private ResultsCollector ResultsCollector {
58      get { return (ResultsCollector)DataTableValuesCollector.Successor; }
59    }
60    #endregion
61
62    #region Storing & Cloning
63    [StorableConstructor]
64    private SingleValueAnalyzer(bool deserializing) : base(deserializing) { }
65    private SingleValueAnalyzer(SingleValueAnalyzer original, Cloner cloner) : base(original, cloner) { }
66    public override IDeepCloneable Clone(Cloner cloner) {
67      return new SingleValueAnalyzer(this, cloner);
68    }
69    #endregion
70    public SingleValueAnalyzer()
71      : base() {
72      #region Create parameters
73      Parameters.Add(new LookupParameter<DoubleValue>("Value", "The value contained in the scope tree which should be analyzed."));
74      Parameters.Add(new ValueLookupParameter<DataTable>("Values", "The data table to store the values."));
75      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The results collection where the analysis values should be stored."));
76      #endregion
77
78      #region Create operators
79      DataTableValuesCollector dataTableValuesCollector = new DataTableValuesCollector();
80      ResultsCollector resultsCollector = new ResultsCollector();
81
82      dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Value", null, ValueParameter.Name));
83      dataTableValuesCollector.DataTableParameter.ActualName = ValuesParameter.Name;
84
85      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Value", null, ValueParameter.Name));
86      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>(ValuesParameter.Name));
87      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
88      #endregion
89
90      #region Create operator graph
91      OperatorGraph.InitialOperator = dataTableValuesCollector;
92      dataTableValuesCollector.Successor = resultsCollector;
93      resultsCollector.Successor = null;
94      #endregion
95    }
96  }
97}
Note: See TracBrowser for help on using the repository browser.