Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Analysis/3.3/PopulationValueAnalyzer.cs @ 3623

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

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

  • added analyzers
File size: 3.5 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 in the current population.
33  /// </summary>
34  [Item("PopulationValueAnalyzer", "An operator which analyzes a value in the current population.")]
35  [StorableClass]
36  public sealed class PopulationValueAnalyzer : AlgorithmOperator, IPopulationAnalyzer {
37    #region Parameter properties
38    public SubScopesLookupParameter<DoubleValue> ValueParameter {
39      get { return (SubScopesLookupParameter<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 PopulationValueAnalyzer(bool deserializing) : base() { }
51    public PopulationValueAnalyzer()
52      : base() {
53      Initialize();
54    }
55
56    private void Initialize() {
57      #region Create parameters
58      Parameters.Add(new SubScopesLookupParameter<DoubleValue>("Value", "The value contained in each solution which should be analyzed."));
59      Parameters.Add(new ValueLookupParameter<DataTable>("Values", "The data table to store the values."));
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 SubScopesLookupParameter<DoubleValue>("Value", null, "Value"));
68      dataTableValuesCollector.DataTableParameter.ActualName = "Values";
69
70      resultsCollector.CollectedValues.Add(new SubScopesLookupParameter<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.