Index: 3.4/Analyzers/MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs =================================================================== --- 3.4/Analyzers/MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs (nonexistent) +++ 3.4/Analyzers/MinAverageMaxSymbolicExpressionNeastedTreeSyzeAnalyzer.cs (working copy) @@ -0,0 +1,95 @@ + +#region License Information +/* HeuristicLab + * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) + * + * This file is part of HeuristicLab. + * + * HeuristicLab is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * HeuristicLab is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with HeuristicLab. If not, see . + */ +#endregion + +using System; +using HeuristicLab.Analysis; +using HeuristicLab.Common; +using HeuristicLab.Core; +using HeuristicLab.Data; +using HeuristicLab.Operators; +using HeuristicLab.Parameters; +using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; +using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; +using HeuristicLab.Problems.DataAnalysis.Symbolic; +using System.Collections.Generic; +using System.Linq; +using HeuristicLab.Optimization; + +namespace HeuristicLab.Problems.DataAnalysis.Symbolic { + /// + /// An operator that tracks the min average and max length of symbolic expression trees. + /// + [Item("MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer", "An operator that tracks the min avgerage and max Neasted Tree Size of symbolic expression trees.")] + [StorableClass] + public sealed class MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer { + private const string ResultsParameterName = "Results"; + private const string MinMaxAvgNeastedTreeSizeResultName = "MinMaxAvgNeastedTreeSize"; + + #region parameter properties + public ValueLookupParameter ResultsParameter { + get { return (ValueLookupParameter)Parameters[ResultsParameterName]; } + } + #endregion + + [StorableConstructor] + private MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer(bool deserializing) : base() { } + private MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer(MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer original, Cloner cloner) + : base(original, cloner) { + AfterDeserialization(); + } + public MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer() + : base() { + } + + [StorableHook(HookType.AfterDeserialization)] + private void AfterDeserialization() { } + + public override IDeepCloneable Clone(Cloner cloner) { + return new MinAverageMaxSymbolicExpressionNeastedTreeSizeAnalyzer(this, cloner); + } + + public override IOperation Apply() { + var trees = SymbolicExpressionTreeParameter.ActualValue; + //var variablesNumber = new DoubleArray(trees.Length); + var variablesNumber = trees.Select(tree => tree.IterateNodesPostfix().Sum(n => n.GetLength())).ToArray(); + var min = variablesNumber.Min(); + var max = variablesNumber.Max(); + var avg = variablesNumber.Average(); + + DataTable table; + if (ResultCollection.ContainsKey(MinMaxAvgNeastedTreeSizeResultName)) { + table = (DataTable)ResultCollection[MinMaxAvgNeastedTreeSizeResultName].Value; + } else { + table = new DataTable("Tree Variables Number"); + ResultCollection.Add(new Result(MinMaxAvgNeastedTreeSizeResultName, table)); + table.Rows.Add(new DataRow("Min") { VisualProperties = { StartIndexZero = true } }); + table.Rows.Add(new DataRow("Max") { VisualProperties = { StartIndexZero = true } }); + table.Rows.Add(new DataRow("Avg") { VisualProperties = { StartIndexZero = true } }); + } + table.Rows["Min"].Values.Add(min); + table.Rows["Max"].Values.Add(max); + table.Rows["Avg"].Values.Add(avg); + + return base.Apply(); + } + } +} Index: 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs =================================================================== --- 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs (nonexistent) +++ 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeComplexcityAnalyzer.cs (working copy) @@ -0,0 +1,108 @@ + +#region License Information +/* HeuristicLab + * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) + * + * This file is part of HeuristicLab. + * + * HeuristicLab is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * HeuristicLab is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with HeuristicLab. If not, see . + */ +#endregion + +using System; +using HeuristicLab.Analysis; +using HeuristicLab.Common; +using HeuristicLab.Core; +using HeuristicLab.Data; +using HeuristicLab.Operators; +using HeuristicLab.Parameters; +using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; +using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; +using HeuristicLab.Problems.DataAnalysis.Symbolic; +using System.Collections.Generic; +using System.Linq; +using HeuristicLab.Optimization; + +namespace HeuristicLab.Problems.DataAnalysis.Symbolic { + /// + /// An operator that tracks the min average and max length of symbolic expression trees. + /// + [Item("MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer", "An operator that tracks the min avgerage and max Complexity of symbolic expression trees.")] + [StorableClass] + public sealed class MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer { + private const string ResultsParameterName = "Results"; + private const string MinMaxAvgComplexityResultName = "MinMaxAvgTreeComplexity"; + + #region parameter properties + public ValueLookupParameter ResultsParameter { + get { return (ValueLookupParameter)Parameters[ResultsParameterName]; } + } + #endregion + + [StorableConstructor] + private MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer(bool deserializing) : base() { } + private MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer(MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer original, Cloner cloner) + : base(original, cloner) { + AfterDeserialization(); + } + public MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer() + : base() { + } + + [StorableHook(HookType.AfterDeserialization)] + private void AfterDeserialization() {} + + public override IDeepCloneable Clone(Cloner cloner) { + return new MinAverageMaxSymbolicExpressionTreeComplexityAnalyzer(this, cloner); + } + + public override IOperation Apply() { + var trees = SymbolicExpressionTreeParameter.ActualValue; + var complexities = trees.Select(SymbolicDataAnalysisModelComplexityCalculator.CalculateComplexity).ToArray(); + + var min = complexities.Min(); + var max = complexities.Max(); + var avg = complexities.Average(); + + //double min = complexities[0], max = complexities[0], avg = 0; + + //foreach (var c in complexities) { + // if (min > c) { + // min = c; + // } + // if (max < c) { + // max = c; + // } + // avg += c; + //} + //avg /= complexities.Length; + + DataTable table; + if (ResultCollection.ContainsKey(MinMaxAvgComplexityResultName)) { + table = (DataTable)ResultCollection[MinMaxAvgComplexityResultName].Value; + } else { + table = new DataTable("Tree Complexity"); + ResultCollection.Add(new Result(MinMaxAvgComplexityResultName, table)); + table.Rows.Add(new DataRow("Min") { VisualProperties = { StartIndexZero = true } }); + table.Rows.Add(new DataRow("Max") { VisualProperties = { StartIndexZero = true } }); + table.Rows.Add(new DataRow("Avg") { VisualProperties = { StartIndexZero = true } }); + } + table.Rows["Min"].Values.Add(min); + table.Rows["Max"].Values.Add(max); + table.Rows["Avg"].Values.Add(avg); + + return base.Apply(); + } + } +} Index: 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs =================================================================== --- 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs (nonexistent) +++ 3.4/Analyzers/MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer.cs (working copy) @@ -0,0 +1,94 @@ +#region License Information +/* HeuristicLab + * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) + * + * This file is part of HeuristicLab. + * + * HeuristicLab is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * HeuristicLab is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with HeuristicLab. If not, see . + */ +#endregion + +using System; +using HeuristicLab.Analysis; +using HeuristicLab.Common; +using HeuristicLab.Core; +using HeuristicLab.Data; +using HeuristicLab.Operators; +using HeuristicLab.Parameters; +using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; +using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; +using HeuristicLab.Problems.DataAnalysis.Symbolic; +using System.Collections.Generic; +using System.Linq; +using HeuristicLab.Optimization; + +namespace HeuristicLab.Problems.DataAnalysis.Symbolic { + /// + /// An operator that tracks the min average and max length of symbolic expression trees. + /// + [Item("MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer", "An operator that tracks the min avgerage and max VariablesNumber of symbolic expression trees.")] + [StorableClass] + public sealed class MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer { + private const string ResultsParameterName = "Results"; + private const string MinMaxAvgVariablesNumberResultName = "MinMaxAvgTreeVariablesNumber"; + + #region parameter properties + public ValueLookupParameter ResultsParameter { + get { return (ValueLookupParameter)Parameters[ResultsParameterName]; } + } + #endregion + + [StorableConstructor] + private MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer(bool deserializing) : base() { } + private MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer(MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer original, Cloner cloner) + : base(original, cloner) { + AfterDeserialization(); + } + public MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer() + : base() { + } + + [StorableHook(HookType.AfterDeserialization)] + private void AfterDeserialization() { } + + public override IDeepCloneable Clone(Cloner cloner) { + return new MinAverageMaxSymbolicExpressionTreeVariablesNumberAnalyzer(this, cloner); + } + + public override IOperation Apply() { + var trees = SymbolicExpressionTreeParameter.ActualValue; + //var variablesNumber = new DoubleArray(trees.Length); + var variablesNumber = trees.Select(tree => tree.IterateNodesPostfix().OfType().Count()).ToArray(); + var min = variablesNumber.Min(); + var max = variablesNumber.Max(); + var avg = variablesNumber.Average(); + + DataTable table; + if (ResultCollection.ContainsKey(MinMaxAvgVariablesNumberResultName)) { + table = (DataTable)ResultCollection[MinMaxAvgVariablesNumberResultName].Value; + } else { + table = new DataTable("Tree Variables Number"); + ResultCollection.Add(new Result(MinMaxAvgVariablesNumberResultName, table)); + table.Rows.Add(new DataRow("Min") { VisualProperties = { StartIndexZero = true } }); + table.Rows.Add(new DataRow("Max") { VisualProperties = { StartIndexZero = true } }); + table.Rows.Add(new DataRow("Avg") { VisualProperties = { StartIndexZero = true } }); + } + table.Rows["Min"].Values.Add(min); + table.Rows["Max"].Values.Add(max); + table.Rows["Avg"].Values.Add(avg); + + return base.Apply(); + } + } +} Index: 3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj =================================================================== --- 3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj (revision 16364) +++ 3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj (working copy) @@ -126,6 +126,9 @@ + + +