Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 11861

Ignore:
Timestamp:
02/02/15 16:14:45 (9 years ago)
Message:

#2175: Merged trunk changes.

Location:
branches/DataAnalysis.ComplexityAnalyzer
Files:
9 edited

Unmodified
Removed
• ## branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj

 r11407 HeuristicLab.Problems.DataAnalysis.Symbolic.RegressionHeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4v4.0v4.5 4AllRules.rulesetfalse 4 AllRules.ruleset false prompt AllRules.ruleset false prompt AllRules.ruleset false prompt AllRules.ruleset false prompt AllRules.ruleset false
• ## branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs

 r11310 eval: Math.Tan, diff: x => 1 + Math.Tan(x) * Math.Tan(x)); private static readonly Func square = UnaryFunc.Factory( eval: x => x * x, diff: x => 2 * x); private static readonly Func erf = UnaryFunc.Factory( eval: alglib.errorfunction, return true; } } if (node.Symbol is Square) { AutoDiff.Term t; if (!TryTransformToAutoDiff(node.GetSubtree(0), variables, parameters, variableNames, out t)) { term = null; return false; } else { term = AutoDiff.TermBuilder.Power(t, 2.0); return true; } } if (node.Symbol is SquareRoot) { AutoDiff.Term t; if (!TryTransformToAutoDiff(node.GetSubtree(0), variables, parameters, variableNames, out t)) { term = null; return false; } else { term = AutoDiff.TermBuilder.Power(t, 0.5); return true; } } if (node.Symbol is Sine) { AutoDiff.Term t; } else { term = tan(t); return true; } } if (node.Symbol is Square) { AutoDiff.Term t; if (!TryTransformToAutoDiff(node.GetSubtree(0), variables, parameters, variableNames, out t)) { term = null; return false; } else { term = square(t); return true; } !(n.Symbol is Logarithm) && !(n.Symbol is Exponential) && !(n.Symbol is SquareRoot) && !(n.Symbol is Square) && !(n.Symbol is Sine) && !(n.Symbol is Cosine) && !(n.Symbol is Tangent) && !(n.Symbol is Square) && !(n.Symbol is Erf) && !(n.Symbol is Norm) &&
• ## branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs

 r11310 using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; using HeuristicLab.Optimization; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; public SymbolicRegressionSolution(ISymbolicRegressionModel model, IRegressionProblemData problemData) : base(model, problemData) { foreach (var node in model.SymbolicExpressionTree.Root.IterateNodesPrefix().OfType()) node.SetGrammar(null); Add(new Result(ModelLengthResultName, "Length of the symbolic regression model.", new IntValue())); Add(new Result(ModelDepthResultName, "Depth of the symbolic regression model.", new IntValue()));
• ## branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisModelComplexityAnalyzer.cs

 r11407 double complexity = 1; for (int i = 0; i < node.SubtreeCount; i++) { complexity *= CalculateComplexity(node.GetSubtree(i)); var nodeComplexity = CalculateComplexity(node.GetSubtree(i)); complexity *=  nodeComplexity > 2 ? nodeComplexity : 2; } return complexity == 1 ? node.SubtreeCount : complexity; double complexity = 1; for (int i = 0; i < node.SubtreeCount; i++) { complexity *= CalculateComplexity(node.GetSubtree(i)); var nodeComplexity = CalculateComplexity(node.GetSubtree(i)); complexity *= nodeComplexity > 2 ? nodeComplexity : 2; } return complexity; return complexity == 1 ? node.SubtreeCount : complexity; } case OpCodes.Sin: { double complexity = CalculateComplexity(node.GetSubtree(0)); return complexity * 10; return Math.Exp(complexity); } case OpCodes.Cos: { double complexity = CalculateComplexity(node.GetSubtree(0)); return complexity * 10; return Math.Exp(complexity); } case OpCodes.Tan: { double complexity = CalculateComplexity(node.GetSubtree(0)); return complexity * 10; return Math.Exp(complexity); } case OpCodes.Exp: { double complexity = CalculateComplexity(node.GetSubtree(0)); return complexity * 10; } return Math.Exp(complexity); } case OpCodes.Log: { double complexity = CalculateComplexity(node.GetSubtree(0)); return complexity * 10; return Math.Exp(complexity); } case OpCodes.Square: { double complexity = CalculateComplexity(node.GetSubtree(0)); return 2 * complexity; return complexity * complexity; } case OpCodes.SquareRoot: { double complexity = CalculateComplexity(node.GetSubtree(0)); return 10 * complexity; return complexity * complexity * complexity; } case OpCodes.Power: {
• ## branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectiveValidationAnalyzer.cs

 r11310 using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Optimization; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; [StorableClass] public abstract class SymbolicDataAnalysisSingleObjectiveValidationAnalyzer : SymbolicDataAnalysisSingleObjectiveAnalyzer, ISymbolicDataAnalysisValidationAnalyzer ISymbolicDataAnalysisValidationAnalyzer, IStochasticOperator where T : class, ISymbolicDataAnalysisSingleObjectiveEvaluator where U : class, IDataAnalysisProblemData {
• ## branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs

 r11310 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); stringBuilder.Append(",0))"); } else if (symbol is IfThenElse) { stringBuilder.Append("IF("); stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + " ) > 0"); stringBuilder.Append(","); stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); stringBuilder.Append(","); stringBuilder.Append(FormatRecursively(node.GetSubtree(2))); stringBuilder.Append(")"); } else if (symbol is VariableCondition) { VariableConditionTreeNode variableConditionTreeNode = node as VariableConditionTreeNode; double threshold = variableConditionTreeNode.Threshold; double slope = variableConditionTreeNode.Slope; string p = "(1 / (1 + EXP(-" + slope.ToString(CultureInfo.InvariantCulture) + "* (" + GetColumnToVariableName(variableConditionTreeNode.VariableName) + "-" + threshold.ToString(CultureInfo.InvariantCulture) + "))))"; stringBuilder.Append("INT(("); stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); stringBuilder.Append("*"); stringBuilder.Append(p); stringBuilder.Append(") + ("); stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); stringBuilder.Append("*("); stringBuilder.Append("1 - " + p + ")"); stringBuilder.Append("))"); } else if (symbol is Xor) { stringBuilder.Append("IF("); stringBuilder.Append("XOR("); stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + ") > 0,"); stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(1)) + ") > 0"); stringBuilder.Append("), 1.0, -1.0)"); } else if (symbol is Or) { stringBuilder.Append("IF("); stringBuilder.Append("OR("); stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + ") > 0,"); stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(1)) + ") > 0"); stringBuilder.Append("), 1.0, -1.0)"); } else if (symbol is And) { stringBuilder.Append("IF("); stringBuilder.Append("AND("); stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(0)) + ") > 0,"); stringBuilder.Append("(" + FormatRecursively(node.GetSubtree(1)) + ") > 0"); stringBuilder.Append("), 1.0, -1.0)"); } else if (symbol is Not) { stringBuilder.Append("IF("); stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); stringBuilder.Append(" > 0, -1.0, 1.0)"); } else if (symbol is GreaterThan) { stringBuilder.Append("IF(("); stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); stringBuilder.Append(") > ("); stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); stringBuilder.Append("), 1.0, -1.0)"); } else if (symbol is LessThan) { stringBuilder.Append("IF(("); stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); stringBuilder.Append(") < ("); stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); stringBuilder.Append("), 1.0, -1.0)"); } else { throw new NotImplementedException("Excel export of " + node.Symbol + " is not implemented.");
• ## branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

 r11310 HeuristicLab.Problems.DataAnalysis.SymbolicHeuristicLab.Problems.DataAnalysis.Symbolic-3.4v4.0v4.5 4AllRules.rulesetfalse 4 AllRules.ruleset false prompt AllRules.ruleset false prompt AllRules.ruleset false prompt AllRules.ruleset false prompt AllRules.ruleset false Code
• ## branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Matching/SymbolicExpressionTreeMatching.cs

 r10562 ﻿using System; ﻿#region License Information /* HeuristicLab * Copyright (C) 2002-2014 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 System.Collections.Generic; using System.Linq; return matrix[m, n] + 1; } /// /// Calculates the difference between two symbolic expression trees. /// /// The first symbolic expression tree /// The second symbolic expression tree /// Returns the root of the subtree (from T1) by which T1 differs from T2, or null if no difference is found. public static ISymbolicExpressionTreeNode Difference(this ISymbolicExpressionTree tree, ISymbolicExpressionTree other) { return Difference(tree.Root, other.Root); } public static ISymbolicExpressionTreeNode Difference(this ISymbolicExpressionTreeNode node, ISymbolicExpressionTreeNode other) { var a = node.IterateNodesPrefix().ToList(); var b = other.IterateNodesPrefix().ToList(); var list = new List(); for (int i = 0, j = 0; i < a.Count && j < b.Count; ++i, ++j) { var s1 = a[i].ToString(); var s2 = b[j].ToString(); if (s1 == s2) continue; list.Add(a[i]); // skip subtrees since the parents are already different i += a[i].SubtreeCount; j += b[j].SubtreeCount; } ISymbolicExpressionTreeNode result = list.Count > 0 ? LowestCommonAncestor(node, list) : null; return result; } private static ISymbolicExpressionTreeNode LowestCommonAncestor(ISymbolicExpressionTreeNode root, List nodes) { if (nodes.Count == 0) throw new ArgumentException("The nodes list should contain at least one element."); if (nodes.Count == 1) return nodes[0]; int minLevel = nodes.Min(x => root.GetBranchLevel(x)); // bring the nodes in the nodes to the same level (relative to the root) for (int i = 0; i < nodes.Count; ++i) { var node = nodes[i]; var level = root.GetBranchLevel(node); for (int j = minLevel; j < level; ++j) node = node.Parent; nodes[i] = node; } // while not all the elements in the nodes are equal, go one level up while (nodes.Any(x => x != nodes[0])) { for (int i = 0; i < nodes.Count; ++i) nodes[i] = nodes[i].Parent; } return nodes[0]; } } }
• ## branches/DataAnalysis.ComplexityAnalyzer/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs

 r11310 private void MergeVariablesAndConstantsInProduct(ISymbolicExpressionTreeNode prod) { var subtrees = new List(prod.Subtrees); prod. while (prod.Subtrees.Count() > 0) prod.RemoveSubtree(0); var groupedVarNodes = from node in subtrees.OfType()
Note: See TracChangeset for help on using the changeset viewer.