1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2018 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 |
|
---|
22 | using HeuristicLab.Analysis;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 | using HeuristicLab.Operators;
|
---|
27 | using HeuristicLab.Optimization;
|
---|
28 | using HeuristicLab.Optimization.Operators;
|
---|
29 | using HeuristicLab.Parameters;
|
---|
30 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
31 |
|
---|
32 | namespace HeuristicLab.Algorithms.RAPGA {
|
---|
33 | /// <summary>
|
---|
34 | /// An operator which analyzes the actual selection pressure.
|
---|
35 | /// </summary>
|
---|
36 | [Item("SelectionPressureAnalyzer", "An operator which analyzes the actual selection pressure.")]
|
---|
37 | [StorableClass]
|
---|
38 | public sealed class SelectionPressureAnalyzer : AlgorithmOperator, IAnalyzer {
|
---|
39 | #region Parameter properties
|
---|
40 | public ILookupParameter<DoubleValue> ActualSelectionPressureParameter {
|
---|
41 | get { return (ILookupParameter<DoubleValue>)Parameters["ActualSelectionPressure"]; }
|
---|
42 | }
|
---|
43 | public IValueLookupParameter<DataTable> SelectionPressureParameter {
|
---|
44 | get { return (IValueLookupParameter<DataTable>)Parameters["SelectionPressure"]; }
|
---|
45 | }
|
---|
46 | public IValueLookupParameter<VariableCollection> ResultsParameter {
|
---|
47 | get { return (IValueLookupParameter<VariableCollection>)Parameters["Results"]; }
|
---|
48 | }
|
---|
49 | #endregion
|
---|
50 |
|
---|
51 | #region Properties
|
---|
52 | public bool EnabledByDefault {
|
---|
53 | get { return true; }
|
---|
54 | }
|
---|
55 | private DataTableValuesCollector DataTableValuesCollector {
|
---|
56 | get { return (DataTableValuesCollector)OperatorGraph.InitialOperator; }
|
---|
57 | }
|
---|
58 | private ResultsCollector ResultsCollector {
|
---|
59 | get { return (ResultsCollector)DataTableValuesCollector.Successor; }
|
---|
60 | }
|
---|
61 | #endregion
|
---|
62 |
|
---|
63 | #region Storing & Cloning
|
---|
64 | [StorableConstructor]
|
---|
65 | private SelectionPressureAnalyzer(bool deserializing) : base(deserializing) { }
|
---|
66 | private SelectionPressureAnalyzer(SelectionPressureAnalyzer original, Cloner cloner) : base(original, cloner) { }
|
---|
67 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
68 | return new SelectionPressureAnalyzer(this, cloner);
|
---|
69 | }
|
---|
70 | #endregion
|
---|
71 | public SelectionPressureAnalyzer()
|
---|
72 | : base() {
|
---|
73 | #region Create parameters
|
---|
74 | Parameters.Add(new LookupParameter<DoubleValue>("ActualSelectionPressure", "The actual selection pressure."));
|
---|
75 | Parameters.Add(new ValueLookupParameter<DataTable>("SelectionPressure", "The data table to store the values."));
|
---|
76 | Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The results collection where the analysis values should be stored."));
|
---|
77 | #endregion
|
---|
78 |
|
---|
79 | #region Create operators
|
---|
80 | DataTableValuesCollector dataTableValuesCollector = new DataTableValuesCollector();
|
---|
81 | ResultsCollector resultsCollector = new ResultsCollector();
|
---|
82 |
|
---|
83 | dataTableValuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("ActualSelectionPressure", null, ActualSelectionPressureParameter.Name));
|
---|
84 | dataTableValuesCollector.DataTableParameter.ActualName = SelectionPressureParameter.Name;
|
---|
85 |
|
---|
86 | resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>(SelectionPressureParameter.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 | }
|
---|