[8016] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[17180] | 3 | * Copyright (C) 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 |
|
---|
| 22 | using HeuristicLab.Common;
|
---|
| 23 | using HeuristicLab.Core;
|
---|
| 24 | using HeuristicLab.Data;
|
---|
| 25 | using HeuristicLab.Operators;
|
---|
| 26 | using HeuristicLab.Optimization;
|
---|
| 27 | using HeuristicLab.Optimization.Operators;
|
---|
| 28 | using HeuristicLab.Parameters;
|
---|
[16565] | 29 | using HEAL.Attic;
|
---|
[8016] | 30 |
|
---|
| 31 | namespace 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).")]
|
---|
[16565] | 36 | [StorableType("A732AA1E-A772-44A4-8DD3-9AB3E3A0C546")]
|
---|
[8016] | 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]
|
---|
[16565] | 64 | private SingleValueAnalyzer(StorableConstructorFlag _) : base(_) { }
|
---|
[8016] | 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 | }
|
---|