1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2015 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.Parameters;
|
---|
29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
30 |
|
---|
31 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
|
---|
32 | [Item("SchemaCleanupOperator", "Operator which removes the schemas from the global scope after they have been evaluated.")]
|
---|
33 | [StorableClass]
|
---|
34 | public class DiversificationStatisticsOperator : SingleSuccessorOperator {
|
---|
35 | private const string NumberOfChangedTreesParameterName = "NumberOfChangedTrees";
|
---|
36 | private const string NumberOfSchemasParameterName = "NumberOfSchemas";
|
---|
37 | private const string AverageSchemaLengthParameterName = "AverageSchemaLength";
|
---|
38 | private const string ResultCollectionParameterName = "Results";
|
---|
39 |
|
---|
40 | public ILookupParameter<IntValue> NumberOfChangedTreesParameter {
|
---|
41 | get { return (ILookupParameter<IntValue>)Parameters[NumberOfChangedTreesParameterName]; }
|
---|
42 | }
|
---|
43 | public ILookupParameter<IntValue> NumberOfSchemasParameter {
|
---|
44 | get { return (ILookupParameter<IntValue>)Parameters[NumberOfSchemasParameterName]; }
|
---|
45 | }
|
---|
46 | public ILookupParameter<DoubleValue> AverageSchemaLengthParameter {
|
---|
47 | get { return (ILookupParameter<DoubleValue>)Parameters[AverageSchemaLengthParameterName]; }
|
---|
48 | }
|
---|
49 | public ILookupParameter<ResultCollection> ResultCollectionParameter {
|
---|
50 | get { return (ILookupParameter<ResultCollection>)Parameters[ResultCollectionParameterName]; }
|
---|
51 | }
|
---|
52 |
|
---|
53 | public DiversificationStatisticsOperator() {
|
---|
54 | Parameters.Add(new LookupParameter<IntValue>(NumberOfChangedTreesParameterName));
|
---|
55 | Parameters.Add(new LookupParameter<IntValue>(NumberOfSchemasParameterName));
|
---|
56 | Parameters.Add(new LookupParameter<DoubleValue>(AverageSchemaLengthParameterName));
|
---|
57 | Parameters.Add(new LookupParameter<ResultCollection>(ResultCollectionParameterName));
|
---|
58 | }
|
---|
59 |
|
---|
60 | protected DiversificationStatisticsOperator(DiversificationStatisticsOperator original, Cloner cloner) : base(original, cloner) { }
|
---|
61 |
|
---|
62 | public override IDeepCloneable Clone(Cloner cloner) { return new DiversificationStatisticsOperator(this, cloner); }
|
---|
63 |
|
---|
64 | [StorableConstructor]
|
---|
65 | protected DiversificationStatisticsOperator(bool deserializing) : base(deserializing) { }
|
---|
66 |
|
---|
67 | public override IOperation Apply() {
|
---|
68 |
|
---|
69 | var results = ResultCollectionParameter.ActualValue;
|
---|
70 | DataTable table;
|
---|
71 | if (!results.ContainsKey("NumberOfChangedTrees")) {
|
---|
72 | table = new DataTable();
|
---|
73 | results.Add(new Result("NumberOfChangedTrees", table));
|
---|
74 | var row = new DataRow("Changed trees");
|
---|
75 | table.Rows.Add(row);
|
---|
76 | }
|
---|
77 | if (!results.ContainsKey("AverageSchemaLength")) {
|
---|
78 | table = new DataTable();
|
---|
79 | results.Add(new Result("AverageSchemaLength", table));
|
---|
80 | var row = new DataRow("Average schema length");
|
---|
81 | table.Rows.Add(row);
|
---|
82 | }
|
---|
83 | if (!results.ContainsKey("NumberOfSchemas")) {
|
---|
84 | table = new DataTable();
|
---|
85 | results.Add(new Result("NumberOfSchemas", table));
|
---|
86 | var row = new DataRow("Number of schemas");
|
---|
87 | table.Rows.Add(row);
|
---|
88 | }
|
---|
89 | ((DataTable)results["NumberOfChangedTrees"].Value).Rows["Changed trees"].Values.Add(NumberOfChangedTreesParameter.ActualValue.Value);
|
---|
90 | ((DataTable)results["AverageSchemaLength"].Value).Rows["Average schema length"].Values.Add(AverageSchemaLengthParameter.ActualValue.Value);
|
---|
91 | ((DataTable)results["NumberOfSchemas"].Value).Rows["Number of schemas"].Values.Add(NumberOfSchemasParameter.ActualValue.Value);
|
---|
92 |
|
---|
93 | return base.Apply();
|
---|
94 | }
|
---|
95 | }
|
---|
96 | }
|
---|