Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2988_ModelsOfModels2/HeuristicLab.Problems.DataAnalysis.Symbolic/new-analyzers.patch @ 18183

Last change on this file since 18183 was 17134, checked in by msemenki, 5 years ago

#2988:

  1. The file system was changed, folders was added and part of files was transferred in these folders.
  2. HelpFunctions class was divided on 2 parts: HelpFuctions for common purposes static functions and SelfConfiguration that include functions for self-configuration mechanism realization (is used in EMMSucsessMap).
  3. Parts of self-configuration mechanism was transferred from EMMSucsessMap.cs to SelfConfiguration.cs. Now EMMSucsessMap used SelfConfiguration like one of data member. Other parts of project was adopted for this changing.
  4. FileComunication class was added. It include the majority of functions for printing to files or reading from files. Here were realized possibility to write and read to hl files.
  5. ModelTreeNode.cs has additional possibility - to write sub-model in string (then it is possible to write it in file).
  6. InfixExpressionFormatter.cs can work with TreeModelNode.
  7. Possibility for different map types to be readable from files was extended and cheeked.
  8. Such parameters like - ClusterNumbers, ClusterNumbersShow, NegbourNumber, NegbourType (that is used only in several maps) was transferred from EMMAlgorithm to Map Parameters. Now EMMBaseMap class inherited from ParameterizedNamedItem (not from Item). And EMMIslandMap and EMMNetworkMap contains their parameters (constructors was modified). CreationMap calls functions were simplified.
  9. Functions for different distance metric calculation was added. Now, it is possible to calculate different types of distances between models (with different random values of constants).
  10. DistanceParametr was added. Now maps can be created according different types of distance calculations.
  11. The class EMMClustering has new name KMeansClusterizationAlgorithm. On KMeansClusterizationAlgorithm bug with bloating of centroids list was fixed. Algorithm was adopted for working with different type of distance metric and get maximum number of iterations.
  12. Possibilities for constants optimization in sub-models an whole tree was added. EMMAlgorithm get new function for evaluation of individuals (and some additional technical stuff for that). Function for trees with model in usual tree transformation and back was added.
  13. EMMAlgorithm was divided on 2 parts:
  • EMMAlgorithm, that contain evolutionary algorithm working with sub-models, and use ready to use maps;
  • ModelSetPreparation, that contain distance calculation, model set simplification and map creation.
File size: 14.6 KB
RevLine 
[17134]1Index: 3.4/Analyzers/MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs
2===================================================================
3--- 3.4/Analyzers/MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs (nonexistent)
4+++ 3.4/Analyzers/MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs (working copy)
5@@ -0,0 +1,95 @@
6+
7+#region License Information
8+/* HeuristicLab
9+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
10+ *
11+ * This file is part of HeuristicLab.
12+ *
13+ * HeuristicLab is free software: you can redistribute it and/or modify
14+ * it under the terms of the GNU General Public License as published by
15+ * the Free Software Foundation, either version 3 of the License, or
16+ * (at your option) any later version.
17+ *
18+ * HeuristicLab is distributed in the hope that it will be useful,
19+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21+ * GNU General Public License for more details.
22+ *
23+ * You should have received a copy of the GNU General Public License
24+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
25+ */
26+#endregion
27+
28+using System;
29+using HeuristicLab.Analysis;
30+using HeuristicLab.Common;
31+using HeuristicLab.Core;
32+using HeuristicLab.Data;
33+using HeuristicLab.Operators;
34+using HeuristicLab.Parameters;
35+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
36+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
37+using HeuristicLab.Problems.DataAnalysis.Symbolic;
38+using System.Collections.Generic;
39+using System.Linq;
40+using HeuristicLab.Optimization;
41+
42+namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
43+  /// <summary>
44+  /// An operator that tracks the min average and max length of symbolic expression trees.
45+  /// </summary>
46+  [Item("MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer", "An operator that tracks the min avgerage and max Neasted Tree Size of symbolic expression trees.")]
47+  [StorableClass]
48+  public sealed class MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer {
49+    private const string ResultsParameterName = "Results";
50+    private const string MinMaxAvgNeastedTreeSizeResultName = "MinMaxAvgNeastedTreeSize";
51+
52+    #region parameter properties
53+    public ValueLookupParameter<VariableCollection> ResultsParameter {
54+      get { return (ValueLookupParameter<VariableCollection>)Parameters[ResultsParameterName]; }
55+    }
56+    #endregion
57+
58+    [StorableConstructor]
59+    private MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer(bool deserializing) : base() { }
60+    private MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer(MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer original, Cloner cloner)
61+      : base(original, cloner) {
62+      AfterDeserialization();
63+    }
64+    public MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer()
65+      : base() {
66+    }
67+
68+    [StorableHook(HookType.AfterDeserialization)]
69+    private void AfterDeserialization() { }
70+
71+    public override IDeepCloneable Clone(Cloner cloner) {
72+      return new MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer(this, cloner);
73+    }
74+
75+    public override IOperation Apply() {
76+      var trees = SymbolicExpressionTreeParameter.ActualValue;
77+      //var variablesNumber = new DoubleArray(trees.Length);
78+      var variablesNumber = trees.Select(tree => tree.IterateNodesPostfix().Sum(n => n.GetLength())).ToArray();
79+      var min = variablesNumber.Min();
80+      var max = variablesNumber.Max();
81+      var avg = variablesNumber.Average();
82+
83+      DataTable table;
84+      if (ResultCollection.ContainsKey(MinMaxAvgNeastedTreeSizeResultName)) {
85+        table = (DataTable)ResultCollection[MinMaxAvgNeastedTreeSizeResultName].Value;
86+      } else {
87+        table = new DataTable("Tree Variables Number");
88+        ResultCollection.Add(new Result(MinMaxAvgNeastedTreeSizeResultName, table));
89+        table.Rows.Add(new DataRow("Min") { VisualProperties = { StartIndexZero = true } });
90+        table.Rows.Add(new DataRow("Max") { VisualProperties = { StartIndexZero = true } });
91+        table.Rows.Add(new DataRow("Avg") { VisualProperties = { StartIndexZero = true } });
92+      }
93+      table.Rows["Min"].Values.Add(min);
94+      table.Rows["Max"].Values.Add(max);
95+      table.Rows["Avg"].Values.Add(avg);
96+
97+      return base.Apply();
98+    }
99+  }
100+}
101Index: 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs
102===================================================================
103--- 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs (nonexistent)
104+++ 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs (working copy)
105@@ -0,0 +1,108 @@
106+
107+#region License Information
108+/* HeuristicLab
109+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
110+ *
111+ * This file is part of HeuristicLab.
112+ *
113+ * HeuristicLab is free software: you can redistribute it and/or modify
114+ * it under the terms of the GNU General Public License as published by
115+ * the Free Software Foundation, either version 3 of the License, or
116+ * (at your option) any later version.
117+ *
118+ * HeuristicLab is distributed in the hope that it will be useful,
119+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
120+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
121+ * GNU General Public License for more details.
122+ *
123+ * You should have received a copy of the GNU General Public License
124+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
125+ */
126+#endregion
127+
128+using System;
129+using HeuristicLab.Analysis;
130+using HeuristicLab.Common;
131+using HeuristicLab.Core;
132+using HeuristicLab.Data;
133+using HeuristicLab.Operators;
134+using HeuristicLab.Parameters;
135+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
136+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
137+using HeuristicLab.Problems.DataAnalysis.Symbolic;
138+using System.Collections.Generic;
139+using System.Linq;
140+using HeuristicLab.Optimization;
141+
142+namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
143+  /// <summary>
144+  /// An operator that tracks the min average and max length of symbolic expression trees.
145+  /// </summary>
146+  [Item("MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer", "An operator that tracks the min avgerage and max Complexity of symbolic expression trees.")]
147+  [StorableClass]
148+  public sealed class MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer {
149+    private const string ResultsParameterName = "Results";
150+    private const string MinMaxAvgComplexityResultName = "MinMaxAvgTreeComplexity";
151+
152+    #region parameter properties
153+    public ValueLookupParameter<VariableCollection> ResultsParameter {
154+      get { return (ValueLookupParameter<VariableCollection>)Parameters[ResultsParameterName]; }
155+    }
156+    #endregion
157+
158+    [StorableConstructor]
159+    private MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer(bool deserializing) : base() { }
160+    private MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer(MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer original, Cloner cloner)
161+      : base(original, cloner) {
162+      AfterDeserialization();
163+    }
164+    public MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer()
165+      : base() {
166+    }
167+
168+    [StorableHook(HookType.AfterDeserialization)]
169+    private void AfterDeserialization() {}
170+
171+    public override IDeepCloneable Clone(Cloner cloner) {
172+      return new MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer(this, cloner);
173+    }
174+
175+    public override IOperation Apply() {
176+      var trees = SymbolicExpressionTreeParameter.ActualValue;
177+      var complexities = trees.Select(SymbolicDataAnalysisModelComplexityCalculator.CalculateComplexity).ToArray();
178+
179+      var min = complexities.Min();
180+      var max = complexities.Max();
181+      var avg = complexities.Average();
182+
183+      //double min = complexities[0], max = complexities[0], avg = 0;
184+
185+      //foreach (var c in complexities) {
186+      //  if (min > c) {
187+      //    min = c;
188+      //  }
189+      //  if (max < c) {
190+      //    max = c;
191+      //  }
192+      //  avg += c;
193+      //}
194+      //avg /= complexities.Length;
195+
196+      DataTable table;
197+      if (ResultCollection.ContainsKey(MinMaxAvgComplexityResultName)) {
198+        table = (DataTable)ResultCollection[MinMaxAvgComplexityResultName].Value;
199+      } else {
200+        table = new DataTable("Tree Complexity");
201+        ResultCollection.Add(new Result(MinMaxAvgComplexityResultName, table));
202+        table.Rows.Add(new DataRow("Min") { VisualProperties = { StartIndexZero = true } });
203+        table.Rows.Add(new DataRow("Max") { VisualProperties = { StartIndexZero = true } });
204+        table.Rows.Add(new DataRow("Avg") { VisualProperties = { StartIndexZero = true } });
205+      }
206+      table.Rows["Min"].Values.Add(min);
207+      table.Rows["Max"].Values.Add(max);
208+      table.Rows["Avg"].Values.Add(avg);
209+
210+      return base.Apply();
211+    }
212+  }
213+}
214Index: 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs
215===================================================================
216--- 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs (nonexistent)
217+++ 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs (working copy)
218@@ -0,0 +1,94 @@
219+#region License Information
220+/* HeuristicLab
221+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
222+ *
223+ * This file is part of HeuristicLab.
224+ *
225+ * HeuristicLab is free software: you can redistribute it and/or modify
226+ * it under the terms of the GNU General Public License as published by
227+ * the Free Software Foundation, either version 3 of the License, or
228+ * (at your option) any later version.
229+ *
230+ * HeuristicLab is distributed in the hope that it will be useful,
231+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
232+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
233+ * GNU General Public License for more details.
234+ *
235+ * You should have received a copy of the GNU General Public License
236+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
237+ */
238+#endregion
239+
240+using System;
241+using HeuristicLab.Analysis;
242+using HeuristicLab.Common;
243+using HeuristicLab.Core;
244+using HeuristicLab.Data;
245+using HeuristicLab.Operators;
246+using HeuristicLab.Parameters;
247+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
248+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
249+using HeuristicLab.Problems.DataAnalysis.Symbolic;
250+using System.Collections.Generic;
251+using System.Linq;
252+using HeuristicLab.Optimization;
253+
254+namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
255+  /// <summary>
256+  /// An operator that tracks the min average and max length of symbolic expression trees.
257+  /// </summary>
258+  [Item("MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer", "An operator that tracks the min avgerage and max VariablesNumber of symbolic expression trees.")]
259+  [StorableClass]
260+  public sealed class MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer {
261+    private const string ResultsParameterName = "Results";
262+    private const string MinMaxAvgVariablesNumberResultName = "MinMaxAvgTreeVariablesNumber";
263+
264+    #region parameter properties
265+    public ValueLookupParameter<VariableCollection> ResultsParameter {
266+      get { return (ValueLookupParameter<VariableCollection>)Parameters[ResultsParameterName]; }
267+    }
268+    #endregion
269+
270+    [StorableConstructor]
271+    private MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer(bool deserializing) : base() { }
272+    private MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer(MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer original, Cloner cloner)
273+      : base(original, cloner) {
274+      AfterDeserialization();
275+    }
276+    public MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer()
277+      : base() {
278+    }
279+
280+    [StorableHook(HookType.AfterDeserialization)]
281+    private void AfterDeserialization() { }
282+
283+    public override IDeepCloneable Clone(Cloner cloner) {
284+      return new MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer(this, cloner);
285+    }
286+
287+    public override IOperation Apply() {
288+      var trees = SymbolicExpressionTreeParameter.ActualValue;
289+      //var variablesNumber = new DoubleArray(trees.Length);
290+      var variablesNumber = trees.Select(tree => tree.IterateNodesPostfix().OfType<IVariableTreeNode>().Count()).ToArray();
291+      var min = variablesNumber.Min();
292+      var max = variablesNumber.Max();
293+      var avg = variablesNumber.Average();
294+
295+      DataTable table;
296+      if (ResultCollection.ContainsKey(MinMaxAvgVariablesNumberResultName)) {
297+        table = (DataTable)ResultCollection[MinMaxAvgVariablesNumberResultName].Value;
298+      } else {
299+        table = new DataTable("Tree Variables Number");
300+        ResultCollection.Add(new Result(MinMaxAvgVariablesNumberResultName, table));
301+        table.Rows.Add(new DataRow("Min") { VisualProperties = { StartIndexZero = true } });
302+        table.Rows.Add(new DataRow("Max") { VisualProperties = { StartIndexZero = true } });
303+        table.Rows.Add(new DataRow("Avg") { VisualProperties = { StartIndexZero = true } });
304+      }
305+      table.Rows["Min"].Values.Add(min);
306+      table.Rows["Max"].Values.Add(max);
307+      table.Rows["Avg"].Values.Add(avg);
308+
309+      return base.Apply();
310+    }
311+  }
312+}
313Index: 3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
314===================================================================
315--- 3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj  (revision 16364)
316+++ 3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj  (working copy)
317@@ -126,6 +126,9 @@
318     <Reference Include="System.Xml" />
319   </ItemGroup>
320   <ItemGroup>
321+    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs" />
322+    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs" />
323+    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs" />
324     <Compile Include="Analyzers\SymbolicDataAnalysisBottomUpDiversityAnalyzer.cs" />
325     <Compile Include="Analyzers\SymbolicDataAnalysisBuildingBlockAnalyzer.cs" />
326     <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs" />
Note: See TracBrowser for help on using the repository browser.