Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Analysis/3.3/SolutionValueAnalyzer.cs @ 3658

Last change on this file since 3658 was 3658, checked in by swagner, 14 years ago

Worked on refactoring of algorithm analysis and tracing (#999)

  • removed specific analyzer interfaces
  • adapted MultiAnalyzer
File size: 3.4 KB
Line 
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
22using HeuristicLab.Core;
23using HeuristicLab.Data;
24using HeuristicLab.Operators;
25using HeuristicLab.Optimization;
26using HeuristicLab.Optimization.Operators;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Analysis {
31  /// <summary>
32  /// An operator which analyzes a value of the current solution.
33  /// </summary>
34  [Item("SolutionValueAnalyzer", "An operator which analyzes a value of the current solution.")]
35  [StorableClass]
36  public sealed class SolutionValueAnalyzer : AlgorithmOperator, IAnalyzer {
37    #region Parameter properties
38    public LookupParameter<DoubleValue> ValueParameter {
39      get { return (LookupParameter<DoubleValue>)Parameters["Value"]; }
40    }
41    public ValueLookupParameter<DataTable> ValuesParameter {
42      get { return (ValueLookupParameter<DataTable>)Parameters["Values"]; }
43    }
44    public ValueLookupParameter<VariableCollection> ResultsParameter {
45      get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
46    }
47    #endregion
48
49    [StorableConstructor]
50    private SolutionValueAnalyzer(bool deserializing) : base() { }
51    public SolutionValueAnalyzer()
52      : base() {
53      Initialize();
54    }
55
56    private void Initialize() {
57      #region Create parameters
58      Parameters.Add(new LookupParameter<DoubleValue>("Value", "The value of the solution which should be analyzed."));
59      Parameters.Add(new ValueLookupParameter<DataTable>("Values", "The data table to store the value."));
60      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The results collection where the analysis values should be stored."));
61      #endregion
62
63      #region Create operators
64      DataTableValuesCollector dataTableValuesCollector = new DataTableValuesCollector();
65      ResultsCollector resultsCollector = new ResultsCollector();
66
67      dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Value", null, "Value"));
68      dataTableValuesCollector.DataTableParameter.ActualName = "Values";
69
70      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Value", null, "Value"));
71      resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Values"));
72      resultsCollector.ResultsParameter.ActualName = "Results";
73      #endregion
74
75      #region Create operator graph
76      OperatorGraph.InitialOperator = dataTableValuesCollector;
77      dataTableValuesCollector.Successor = resultsCollector;
78      resultsCollector.Successor = null;
79      #endregion
80    }
81  }
82}
Note: See TracBrowser for help on using the repository browser.