- Timestamp:
- 06/08/11 10:42:57 (14 years ago)
- Location:
- branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisAlleleFrequencyAnalyzer.cs
r6135 r6387 88 88 StringBuilder builder = new StringBuilder(); 89 89 builder.Append("(" + tree.ToString()); 90 for (int i = 0; i < tree.Subtree sCount; i++) {90 for (int i = 0; i < tree.SubtreeCount; i++) { 91 91 builder.Append(" " + GetTextualRepresentationFromSubtreeOfDepth(tree.GetSubtree(i), d - 1)); 92 92 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r5817 r6387 73 73 FormatBegin(node, strBuilder); 74 74 75 if (node.Subtree sCount > 0) {75 if (node.SubtreeCount > 0) { 76 76 strBuilder.Append(FormatRecursively(node.GetSubtree(0))); 77 77 } … … 91 91 strBuilder.Append(@" \left( "); 92 92 } else if (node.Symbol is Subtraction) { 93 if (node.Subtree sCount == 1) {93 if (node.SubtreeCount == 1) { 94 94 strBuilder.Append(@"- \left("); 95 95 } else { … … 98 98 } else if (node.Symbol is Multiplication) { 99 99 } else if (node.Symbol is Division) { 100 if (node.Subtree sCount == 1) {100 if (node.SubtreeCount == 1) { 101 101 strBuilder.Append(@" \cfrac{1}{"); 102 102 } else { … … 105 105 } else if (node.Symbol is Average) { 106 106 // skip output of (1/1) if only one subtree 107 if (node.Subtree sCount > 1) {108 strBuilder.Append(@" \cfrac{1}{" + node.Subtree sCount + @"}");107 if (node.SubtreeCount > 1) { 108 strBuilder.Append(@" \cfrac{1}{" + node.SubtreeCount + @"}"); 109 109 } 110 110 strBuilder.Append(@" \left("); … … 246 246 } else if (node.Symbol is Division) { 247 247 strBuilder.Append("} "); 248 if (node.Subtree sCount > 1)248 if (node.SubtreeCount > 1) 249 249 strBuilder.Append("{1} "); 250 for (int i = 1; i < node.Subtree sCount; i++) {250 for (int i = 1; i < node.SubtreeCount; i++) { 251 251 strBuilder.Append(" } "); 252 252 } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs
r5809 r6387 106 106 107 107 if (symbol is Addition) { 108 for (int i = 0; i < node.Subtree sCount; i++) {108 for (int i = 0; i < node.SubtreeCount; i++) { 109 109 if (i > 0) stringBuilder.Append("+"); 110 110 stringBuilder.Append(FormatRecursively(node.GetSubtree(i))); … … 112 112 } else if (symbol is And) { 113 113 stringBuilder.Append("(("); 114 for (int i = 0; i < node.Subtree sCount; i++) {114 for (int i = 0; i < node.SubtreeCount; i++) { 115 115 if (i > 0) stringBuilder.Append("&"); 116 116 stringBuilder.Append("(("); … … 121 121 } else if (symbol is Average) { 122 122 stringBuilder.Append("(1/"); 123 stringBuilder.Append(node.Subtree sCount);123 stringBuilder.Append(node.SubtreeCount); 124 124 stringBuilder.Append(")*("); 125 for (int i = 0; i < node.Subtree sCount; i++) {125 for (int i = 0; i < node.SubtreeCount; i++) { 126 126 if (i > 0) stringBuilder.Append("+"); 127 127 stringBuilder.Append("("); … … 138 138 stringBuilder.Append(")"); 139 139 } else if (symbol is Division) { 140 if (node.Subtree sCount == 1) {140 if (node.SubtreeCount == 1) { 141 141 stringBuilder.Append("1/"); 142 142 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); … … 144 144 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 145 145 stringBuilder.Append("/("); 146 for (int i = 1; i < node.Subtree sCount; i++) {146 for (int i = 1; i < node.SubtreeCount; i++) { 147 147 if (i > 1) stringBuilder.Append("*"); 148 148 stringBuilder.Append(FormatRecursively(node.GetSubtree(i))); … … 187 187 stringBuilder.Append(")"); 188 188 } else if (symbol is Multiplication) { 189 for (int i = 0; i < node.Subtree sCount; i++) {189 for (int i = 0; i < node.SubtreeCount; i++) { 190 190 if (i > 0) stringBuilder.Append("*"); 191 191 stringBuilder.Append(FormatRecursively(node.GetSubtree(i))); … … 197 197 } else if (symbol is Or) { 198 198 stringBuilder.Append("(("); 199 for (int i = 0; i < node.Subtree sCount; i++) {199 for (int i = 0; i < node.SubtreeCount; i++) { 200 200 if (i > 0) stringBuilder.Append("|"); 201 201 stringBuilder.Append("(("); … … 209 209 stringBuilder.Append(")"); 210 210 } else if (symbol is Subtraction) { 211 if (node.Subtree sCount == 1) {211 if (node.SubtreeCount == 1) { 212 212 stringBuilder.Append("-1*"); 213 213 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 214 214 } else { 215 215 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 216 for (int i = 1; i < node.Subtree sCount; i++) {216 for (int i = 1; i < node.SubtreeCount; i++) { 217 217 stringBuilder.Append("-"); 218 218 stringBuilder.Append(FormatRecursively(node.GetSubtree(i))); -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
r5936 r6387 64 64 private ISymbolicExpressionTreeNode MacroExpand(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode node, IList<ISymbolicExpressionTreeNode> argumentTrees) { 65 65 List<ISymbolicExpressionTreeNode> subtrees = new List<ISymbolicExpressionTreeNode>(node.Subtrees); 66 while (node.Subtree sCount > 0) node.RemoveSubtree(0);66 while (node.SubtreeCount > 0) node.RemoveSubtree(0); 67 67 if (node.Symbol is InvokeFunction) { 68 68 var invokeSym = node.Symbol as InvokeFunction; … … 901 901 // x0 * x1 * .. * xn * -1 => x0 * x1 * .. * -xn 902 902 var lastSubTree = x.Subtrees.Last(); 903 x.RemoveSubtree(x.Subtree sCount - 1);903 x.RemoveSubtree(x.SubtreeCount - 1); 904 904 x.AddSubtree(Negate(lastSubTree)); // last is maybe a constant, prefer to negate the constant 905 905 } else { -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Addition.cs
r5809 r6387 22 22 using HeuristicLab.Common; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;26 26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 27 27 [StorableClass] 28 28 [Item("Addition", "Symbol that represents the + operator.")] 29 29 public sealed class Addition : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = byte.MaxValue; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Addition(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/And.cs
r5809 r6387 28 28 [Item("And", "Symbol that represents the boolean AND operator.")] 29 29 public sealed class And : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = byte.MaxValue; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private And(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Average.cs
r5809 r6387 28 28 [Item("Average", "Symbol that represents the average (arithmetic mean) function.")] 29 29 public sealed class Average : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = byte.MaxValue; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Average(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Constant.cs
r5809 r6387 88 88 } 89 89 90 private const int minimumArity = 0; 91 private const int maximumArity = 0; 92 93 public override int MinimumArity { 94 get { return minimumArity; } 95 } 96 public override int MaximumArity { 97 get { return maximumArity; } 98 } 90 99 #endregion 100 91 101 [StorableConstructor] 92 102 private Constant(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Cosine.cs
r5809 r6387 28 28 [Item("Cosine", "Symbol that represents the cosine function.")] 29 29 public sealed class Cosine : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = 1; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Cosine(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Derivative.cs
r5809 r6387 28 28 [Item("Derivative", "Represents the derivative over the specified subtree.")] 29 29 public sealed class Derivative : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = 1; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Derivative(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Division.cs
r5809 r6387 28 28 [Item("Division", "Symbol that represents the / operator.")] 29 29 public sealed class Division : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = byte.MaxValue; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Division(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Exponential.cs
r5809 r6387 28 28 [Item("Exponential", "Symbol that represents the exponential function.")] 29 29 public sealed class Exponential : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = 1; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Exponential(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/GreaterThan.cs
r5809 r6387 28 28 [Item("GreaterThan", "Symbol that represents a greater than relation.")] 29 29 public sealed class GreaterThan : Symbol { 30 private const int minimumArity = 2; 31 private const int maximumArity = 2; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private GreaterThan(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/IfThenElse.cs
r5809 r6387 28 28 [Item("IfThenElse", "Symbol that represents a conditional operator.")] 29 29 public sealed class IfThenElse : Symbol { 30 private const int minimumArity = 3; 31 private const int maximumArity = 3; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private IfThenElse(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Integral.cs
r5809 r6387 27 27 [Item("Integral", "Represents the integral over the specified subtree.")] 28 28 public sealed class Integral : LaggedSymbol { 29 private const int minimumArity = 1; 30 private const int maximumArity = 1; 31 32 public override int MinimumArity { 33 get { return minimumArity; } 34 } 35 public override int MaximumArity { 36 get { return maximumArity; } 37 } 38 29 39 [StorableConstructor] 30 40 private Integral(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/LessThan.cs
r5809 r6387 28 28 [Item("LessThan", "Symbol that represents a less than relation.")] 29 29 public sealed class LessThan : Symbol { 30 private const int minimumArity = 2; 31 private const int maximumArity = 2; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private LessThan(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Logarithm.cs
r5809 r6387 28 28 [Item("Logarithm", "Symbol that represents the logarithm function.")] 29 29 public sealed class Logarithm : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = 1; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Logarithm(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Multiplication.cs
r5809 r6387 28 28 [Item("Multiplication", "Symbol that represents the * operator.")] 29 29 public sealed class Multiplication : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = byte.MaxValue; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Multiplication(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Not.cs
r5809 r6387 28 28 [Item("Not", "Symbol that represents the boolean NOT operator.")] 29 29 public sealed class Not : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = 1; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Not(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Or.cs
r5809 r6387 28 28 [Item("Or", "Symbol that represents the boolean OR operator.")] 29 29 public sealed class Or : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = byte.MaxValue; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Or(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Power.cs
r5809 r6387 28 28 [Item("Power", "Symbol that represents the power function.")] 29 29 public sealed class Power : Symbol { 30 private const int minimumArity = 2; 31 private const int maximumArity = 2; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Power(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Root.cs
r5809 r6387 28 28 [Item("Root", "Symbol that represents the n-th root function.")] 29 29 public sealed class Root : Symbol { 30 private const int minimumArity = 2; 31 private const int maximumArity = 2; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Root(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Sine.cs
r5809 r6387 28 28 [Item("Sine", "Symbol that represents the sine function.")] 29 29 public sealed class Sine : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = 1; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Sine(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Subtraction.cs
r5809 r6387 28 28 [Item("Subtraction", "Symbol that represents the - operator.")] 29 29 public sealed class Subtraction : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = byte.MaxValue; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Subtraction(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Tangent.cs
r5809 r6387 28 28 [Item("Tangent", "Symbol that represents the tangent trigonometric function.")] 29 29 public sealed class Tangent : Symbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = 1; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private Tangent(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/TimeLag.cs
r5809 r6387 28 28 [Item("TimeLag", "Represents a symblol whose evaluation is shifted.")] 29 29 public sealed class TimeLag : LaggedSymbol { 30 private const int minimumArity = 1; 31 private const int maximumArity = 1; 32 33 public override int MinimumArity { 34 get { return minimumArity; } 35 } 36 public override int MaximumArity { 37 get { return maximumArity; } 38 } 39 30 40 [StorableConstructor] 31 41 private TimeLag(bool deserializing) : base(deserializing) { } -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Variable.cs
r6284 r6387 100 100 } 101 101 } 102 103 private const int minimumArity = 0; 104 private const int maximumArity = 0; 105 106 public override int MinimumArity { 107 get { return minimumArity; } 108 } 109 public override int MaximumArity { 110 get { return maximumArity; } 111 } 102 112 #endregion 113 103 114 [StorableConstructor] 104 115 protected Variable(bool deserializing) -
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/VariableCondition.cs
r5809 r6387 138 138 } 139 139 } 140 141 private const int minimumArity = 2; 142 private const int maximumArity = 2; 143 144 public override int MinimumArity { 145 get { return minimumArity; } 146 } 147 public override int MaximumArity { 148 get { return maximumArity; } 149 } 140 150 #endregion 141 151
Note: See TracChangeset
for help on using the changeset viewer.