Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 17582 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
  • 3.4/Analyzers/MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs

     
     1
     2#region License Information
     3/* HeuristicLab
     4 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     5 *
     6 * This file is part of HeuristicLab.
     7 *
     8 * HeuristicLab is free software: you can redistribute it and/or modify
     9 * it under the terms of the GNU General Public License as published by
     10 * the Free Software Foundation, either version 3 of the License, or
     11 * (at your option) any later version.
     12 *
     13 * HeuristicLab is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 * GNU General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU General Public License
     19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     20 */
     21#endregion
     22
     23using System;
     24using HeuristicLab.Analysis;
     25using HeuristicLab.Common;
     26using HeuristicLab.Core;
     27using HeuristicLab.Data;
     28using HeuristicLab.Operators;
     29using HeuristicLab.Parameters;
     30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     32using HeuristicLab.Problems.DataAnalysis.Symbolic;
     33using System.Collections.Generic;
     34using System.Linq;
     35using HeuristicLab.Optimization;
     36
     37namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     38  /// <summary>
     39  /// An operator that tracks the min average and max length of symbolic expression trees.
     40  /// </summary>
     41  [Item("MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer", "An operator that tracks the min avgerage and max Neasted Tree Size of symbolic expression trees.")]
     42  [StorableClass]
     43  public sealed class MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer {
     44    private const string ResultsParameterName = "Results";
     45    private const string MinMaxAvgNeastedTreeSizeResultName = "MinMaxAvgNeastedTreeSize";
     46
     47    #region parameter properties
     48    public ValueLookupParameter<VariableCollection> ResultsParameter {
     49      get { return (ValueLookupParameter<VariableCollection>)Parameters[ResultsParameterName]; }
     50    }
     51    #endregion
     52
     53    [StorableConstructor]
     54    private MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer(bool deserializing) : base() { }
     55    private MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer(MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer original, Cloner cloner)
     56      : base(original, cloner) {
     57      AfterDeserialization();
     58    }
     59    public MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer()
     60      : base() {
     61    }
     62
     63    [StorableHook(HookType.AfterDeserialization)]
     64    private void AfterDeserialization() { }
     65
     66    public override IDeepCloneable Clone(Cloner cloner) {
     67      return new MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer(this, cloner);
     68    }
     69
     70    public override IOperation Apply() {
     71      var trees = SymbolicExpressionTreeParameter.ActualValue;
     72      //var variablesNumber = new DoubleArray(trees.Length);
     73      var variablesNumber = trees.Select(tree => tree.IterateNodesPostfix().Sum(n => n.GetLength())).ToArray();
     74      var min = variablesNumber.Min();
     75      var max = variablesNumber.Max();
     76      var avg = variablesNumber.Average();
     77
     78      DataTable table;
     79      if (ResultCollection.ContainsKey(MinMaxAvgNeastedTreeSizeResultName)) {
     80        table = (DataTable)ResultCollection[MinMaxAvgNeastedTreeSizeResultName].Value;
     81      } else {
     82        table = new DataTable("Tree Variables Number");
     83        ResultCollection.Add(new Result(MinMaxAvgNeastedTreeSizeResultName, table));
     84        table.Rows.Add(new DataRow("Min") { VisualProperties = { StartIndexZero = true } });
     85        table.Rows.Add(new DataRow("Max") { VisualProperties = { StartIndexZero = true } });
     86        table.Rows.Add(new DataRow("Avg") { VisualProperties = { StartIndexZero = true } });
     87      }
     88      table.Rows["Min"].Values.Add(min);
     89      table.Rows["Max"].Values.Add(max);
     90      table.Rows["Avg"].Values.Add(avg);
     91
     92      return base.Apply();
     93    }
     94  }
     95}
  • 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs

     
     1
     2#region License Information
     3/* HeuristicLab
     4 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     5 *
     6 * This file is part of HeuristicLab.
     7 *
     8 * HeuristicLab is free software: you can redistribute it and/or modify
     9 * it under the terms of the GNU General Public License as published by
     10 * the Free Software Foundation, either version 3 of the License, or
     11 * (at your option) any later version.
     12 *
     13 * HeuristicLab is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 * GNU General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU General Public License
     19 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     20 */
     21#endregion
     22
     23using System;
     24using HeuristicLab.Analysis;
     25using HeuristicLab.Common;
     26using HeuristicLab.Core;
     27using HeuristicLab.Data;
     28using HeuristicLab.Operators;
     29using HeuristicLab.Parameters;
     30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     32using HeuristicLab.Problems.DataAnalysis.Symbolic;
     33using System.Collections.Generic;
     34using System.Linq;
     35using HeuristicLab.Optimization;
     36
     37namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     38  /// <summary>
     39  /// An operator that tracks the min average and max length of symbolic expression trees.
     40  /// </summary>
     41  [Item("MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer", "An operator that tracks the min avgerage and max Complexity of symbolic expression trees.")]
     42  [StorableClass]
     43  public sealed class MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer {
     44    private const string ResultsParameterName = "Results";
     45    private const string MinMaxAvgComplexityResultName = "MinMaxAvgTreeComplexity";
     46
     47    #region parameter properties
     48    public ValueLookupParameter<VariableCollection> ResultsParameter {
     49      get { return (ValueLookupParameter<VariableCollection>)Parameters[ResultsParameterName]; }
     50    }
     51    #endregion
     52
     53    [StorableConstructor]
     54    private MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer(bool deserializing) : base() { }
     55    private MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer(MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer original, Cloner cloner)
     56      : base(original, cloner) {
     57      AfterDeserialization();
     58    }
     59    public MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer()
     60      : base() {
     61    }
     62
     63    [StorableHook(HookType.AfterDeserialization)]
     64    private void AfterDeserialization() {}
     65
     66    public override IDeepCloneable Clone(Cloner cloner) {
     67      return new MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer(this, cloner);
     68    }
     69
     70    public override IOperation Apply() {
     71      var trees = SymbolicExpressionTreeParameter.ActualValue;
     72      var complexities = trees.Select(SymbolicDataAnalysisModelComplexityCalculator.CalculateComplexity).ToArray();
     73
     74      var min = complexities.Min();
     75      var max = complexities.Max();
     76      var avg = complexities.Average();
     77
     78      //double min = complexities[0], max = complexities[0], avg = 0;
     79
     80      //foreach (var c in complexities) {
     81      //  if (min > c) {
     82      //    min = c;
     83      //  }
     84      //  if (max < c) {
     85      //    max = c;
     86      //  }
     87      //  avg += c;
     88      //}
     89      //avg /= complexities.Length;
     90
     91      DataTable table;
     92      if (ResultCollection.ContainsKey(MinMaxAvgComplexityResultName)) {
     93        table = (DataTable)ResultCollection[MinMaxAvgComplexityResultName].Value;
     94      } else {
     95        table = new DataTable("Tree Complexity");
     96        ResultCollection.Add(new Result(MinMaxAvgComplexityResultName, table));
     97        table.Rows.Add(new DataRow("Min") { VisualProperties = { StartIndexZero = true } });
     98        table.Rows.Add(new DataRow("Max") { VisualProperties = { StartIndexZero = true } });
     99        table.Rows.Add(new DataRow("Avg") { VisualProperties = { StartIndexZero = true } });
     100      }
     101      table.Rows["Min"].Values.Add(min);
     102      table.Rows["Max"].Values.Add(max);
     103      table.Rows["Avg"].Values.Add(avg);
     104
     105      return base.Apply();
     106    }
     107  }
     108}
  • 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs

     
     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
     22using System;
     23using HeuristicLab.Analysis;
     24using HeuristicLab.Common;
     25using HeuristicLab.Core;
     26using HeuristicLab.Data;
     27using HeuristicLab.Operators;
     28using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     31using HeuristicLab.Problems.DataAnalysis.Symbolic;
     32using System.Collections.Generic;
     33using System.Linq;
     34using HeuristicLab.Optimization;
     35
     36namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     37  /// <summary>
     38  /// An operator that tracks the min average and max length of symbolic expression trees.
     39  /// </summary>
     40  [Item("MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer", "An operator that tracks the min avgerage and max VariablesNumber of symbolic expression trees.")]
     41  [StorableClass]
     42  public sealed class MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer {
     43    private const string ResultsParameterName = "Results";
     44    private const string MinMaxAvgVariablesNumberResultName = "MinMaxAvgTreeVariablesNumber";
     45
     46    #region parameter properties
     47    public ValueLookupParameter<VariableCollection> ResultsParameter {
     48      get { return (ValueLookupParameter<VariableCollection>)Parameters[ResultsParameterName]; }
     49    }
     50    #endregion
     51
     52    [StorableConstructor]
     53    private MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer(bool deserializing) : base() { }
     54    private MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer(MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer original, Cloner cloner)
     55      : base(original, cloner) {
     56      AfterDeserialization();
     57    }
     58    public MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer()
     59      : base() {
     60    }
     61
     62    [StorableHook(HookType.AfterDeserialization)]
     63    private void AfterDeserialization() { }
     64
     65    public override IDeepCloneable Clone(Cloner cloner) {
     66      return new MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer(this, cloner);
     67    }
     68
     69    public override IOperation Apply() {
     70      var trees = SymbolicExpressionTreeParameter.ActualValue;
     71      //var variablesNumber = new DoubleArray(trees.Length);
     72      var variablesNumber = trees.Select(tree => tree.IterateNodesPostfix().OfType<IVariableTreeNode>().Count()).ToArray();
     73      var min = variablesNumber.Min();
     74      var max = variablesNumber.Max();
     75      var avg = variablesNumber.Average();
     76
     77      DataTable table;
     78      if (ResultCollection.ContainsKey(MinMaxAvgVariablesNumberResultName)) {
     79        table = (DataTable)ResultCollection[MinMaxAvgVariablesNumberResultName].Value;
     80      } else {
     81        table = new DataTable("Tree Variables Number");
     82        ResultCollection.Add(new Result(MinMaxAvgVariablesNumberResultName, table));
     83        table.Rows.Add(new DataRow("Min") { VisualProperties = { StartIndexZero = true } });
     84        table.Rows.Add(new DataRow("Max") { VisualProperties = { StartIndexZero = true } });
     85        table.Rows.Add(new DataRow("Avg") { VisualProperties = { StartIndexZero = true } });
     86      }
     87      table.Rows["Min"].Values.Add(min);
     88      table.Rows["Max"].Values.Add(max);
     89      table.Rows["Avg"].Values.Add(avg);
     90
     91      return base.Apply();
     92    }
     93  }
     94}
  • 3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

     
    126126    <Reference Include="System.Xml" />
    127127  </ItemGroup>
    128128  <ItemGroup>
     129    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs" />
     130    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs" />
     131    <Compile Include="Analyzers\MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs" />
    129132    <Compile Include="Analyzers\SymbolicDataAnalysisBottomUpDiversityAnalyzer.cs" />
    130133    <Compile Include="Analyzers\SymbolicDataAnalysisBuildingBlockAnalyzer.cs" />
    131134    <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs" />
Note: See TracBrowser for help on using the repository browser.