Changeset 17503 for branches/2968_infix_string_formatter/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars
- Timestamp:
- 04/10/20 13:10:26 (5 years ago)
- Location:
- branches/2968_infix_string_formatter/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2968_infix_string_formatter/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/2968_infix_string_formatter/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/ArithmeticExpressionGrammar.cs
r15583 r17503 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System.Collections.Generic; 23 using HEAL.Attic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;27 27 using HeuristicLab.PluginInfrastructure; 28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 30 30 [NonDiscoverableType] 31 [Storable Class]31 [StorableType("FCBA02B7-5D29-42F5-A64C-A60AD8EA475D")] 32 32 [Item("ArithmeticExpressionGrammar", "Represents a grammar for functional expressions using only arithmetic operations.")] 33 public class ArithmeticExpressionGrammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar {33 public class ArithmeticExpressionGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar { 34 34 35 35 [StorableConstructor] 36 protected ArithmeticExpressionGrammar( bool deserializing) : base(deserializing) { }36 protected ArithmeticExpressionGrammar(StorableConstructorFlag _) : base(_) { } 37 37 protected ArithmeticExpressionGrammar(ArithmeticExpressionGrammar original, Cloner cloner) : base(original, cloner) { } 38 38 public ArithmeticExpressionGrammar() … … 56 56 var factorVariableSymbol = new FactorVariable(); 57 57 58 var allSymbols = new List<Symbol>() { add, sub, mul, div, constant, variableSymbol, binFactorVariableSymbol, factorVariableSymbol };58 var allSymbols = new List<Symbol>() { add, sub, mul, div, constant, variableSymbol, binFactorVariableSymbol, factorVariableSymbol }; 59 59 var functionSymbols = new List<Symbol>() { add, sub, mul, div }; 60 60 -
branches/2968_infix_string_formatter/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs
r15583 r17503 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;28 28 29 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 30 [Storable Class]30 [StorableType("44B0829C-1CB5-4BE9-9514-BBA54FAB2912")] 31 31 [Item("FullFunctionalExpressionGrammar", "Represents a grammar for functional expressions using all available functions.")] 32 public class FullFunctionalExpressionGrammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar {32 public class FullFunctionalExpressionGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar { 33 33 [StorableConstructor] 34 protected FullFunctionalExpressionGrammar( bool deserializing) : base(deserializing) { }34 protected FullFunctionalExpressionGrammar(StorableConstructorFlag _) : base(_) { } 35 35 protected FullFunctionalExpressionGrammar(FullFunctionalExpressionGrammar original, Cloner cloner) : base(original, cloner) { } 36 36 public FullFunctionalExpressionGrammar() … … 48 48 var mul = new Multiplication(); 49 49 var div = new Division(); 50 var aq = new AnalyticQuotient(); 50 51 var mean = new Average(); 51 52 var sin = new Sine(); … … 53 54 var tan = new Tangent(); 54 55 var log = new Logarithm(); 56 var abs = new Absolute(); 57 var tanh = new HyperbolicTangent(); 55 58 var pow = new Power(); 56 59 pow.InitialFrequency = 0.0; 57 60 var square = new Square(); 58 61 square.InitialFrequency = 0.0; 62 var cube = new Cube(); 63 cube.InitialFrequency = 0.0; 59 64 var root = new Root(); 60 65 root.InitialFrequency = 0.0; 61 66 var sqrt = new SquareRoot(); 62 67 sqrt.InitialFrequency = 0.0; 68 var cubeRoot = new CubeRoot(); 69 cubeRoot.InitialFrequency = 0.0; 63 70 var airyA = new AiryA(); 64 71 airyA.InitialFrequency = 0.0; … … 123 130 autoregressiveVariable.Enabled = false; 124 131 125 var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, square, pow, sqrt, root, exp,132 var allSymbols = new List<Symbol>() { add, sub, mul, div, aq, mean, abs, sin, cos, tan, log, square, cube, pow, sqrt, cubeRoot, root, exp, tanh, 126 133 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral, 127 134 @if, gt, lt, and, or, not,xor, timeLag, integral, derivative, constant, variableSymbol, binFactorVariable, factorVariable, laggedVariable,autoregressiveVariable, variableCondition }; 128 var unaryFunctionSymbols = new List<Symbol>() { square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative,135 var unaryFunctionSymbols = new List<Symbol>() { abs, square, sqrt, cube, cubeRoot, sin, cos, tan, log, exp, tanh, not, timeLag, integral, derivative, 129 136 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral 130 137 }; 131 138 132 var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, variableCondition };139 var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, aq, variableCondition }; 133 140 var ternarySymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or, xor }; 134 141 var terminalSymbols = new List<Symbol>() { variableSymbol, binFactorVariable, factorVariable, constant, laggedVariable, autoregressiveVariable }; -
branches/2968_infix_string_formatter/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r15583 r17503 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2018Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System.Collections.Generic; 23 23 using System.Linq; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;28 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 29 [Storable Class]29 [StorableType("36A22322-0627-4E25-A468-F2A788AF6D46")] 30 30 [Item("TypeCoherentExpressionGrammar", "Represents a grammar for functional expressions in which special syntactic constraints are enforced so that boolean and real-valued expressions are not mixed.")] 31 public class TypeCoherentExpressionGrammar : SymbolicExpressionGrammar, ISymbolicDataAnalysisGrammar {31 public class TypeCoherentExpressionGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar { 32 32 private const string ArithmeticFunctionsName = "Arithmetic Functions"; 33 33 private const string TrigonometricFunctionsName = "Trigonometric Functions"; … … 44 44 45 45 [StorableConstructor] 46 protected TypeCoherentExpressionGrammar( bool deserializing) : base(deserializing) { }46 protected TypeCoherentExpressionGrammar(StorableConstructorFlag _) : base(_) { } 47 47 protected TypeCoherentExpressionGrammar(TypeCoherentExpressionGrammar original, Cloner cloner) : base(original, cloner) { } 48 48 public TypeCoherentExpressionGrammar() … … 69 69 var root = new Root(); 70 70 var sqrt = new SquareRoot(); 71 var cube = new Cube(); 72 var cubeRoot = new CubeRoot(); 71 73 var exp = new Exponential(); 74 var abs = new Absolute(); 72 75 73 76 var airyA = new AiryA(); … … 82 85 var gamma = new Gamma(); 83 86 var hypCosineIntegral = new HyperbolicCosineIntegral(); 87 var tanh = new HyperbolicTangent(); 84 88 var hypSineIntegral = new HyperbolicSineIntegral(); 85 89 var norm = new Norm(); 86 90 var psi = new Psi(); 87 91 var sineIntegral = new SineIntegral(); 92 var analyticalQuotient = new AnalyticQuotient(); 88 93 89 94 var @if = new IfThenElse(); … … 112 117 #region group symbol declaration 113 118 var arithmeticSymbols = new GroupSymbol(ArithmeticFunctionsName, new List<ISymbol>() { add, sub, mul, div, mean }); 114 var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan });119 var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan, tanh }); 115 120 var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log }); 116 var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { a iryA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi,117 fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral });121 var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { abs, airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, 122 fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral, analyticalQuotient}); 118 123 var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, variableSymbol, binFactorVariable, factorVariable }); 119 124 var realValuedSymbols = new GroupSymbol(RealValuedSymbolsName, new List<ISymbol>() { arithmeticSymbols, trigonometricSymbols, exponentialAndLogarithmicSymbols, specialFunctions, terminalSymbols }); 120 125 121 var powerSymbols = new GroupSymbol(PowerFunctionsName, new List<ISymbol> { square, pow, sqrt, root });126 var powerSymbols = new GroupSymbol(PowerFunctionsName, new List<ISymbol> { square, pow, sqrt, root, cube, cubeRoot }); 122 127 123 128 var conditionSymbols = new GroupSymbol(ConditionsName, new List<ISymbol> { @if, variableCondition }); … … 140 145 SetSubtreeCount(root, 2, 2); 141 146 SetSubtreeCount(square, 1, 1); 147 SetSubtreeCount(cube, 1, 1); 142 148 SetSubtreeCount(sqrt, 1, 1); 149 SetSubtreeCount(cubeRoot, 1, 1); 143 150 SetSubtreeCount(exponentialAndLogarithmicSymbols, 1, 1); 144 SetSubtreeCount(specialFunctions, 1, 1); 151 foreach (var sy in specialFunctions.Symbols.Except(new[] { analyticalQuotient })) { 152 SetSubtreeCount(sy, 1, 1); 153 } 154 SetSubtreeCount(analyticalQuotient, 2, 2); 155 145 156 SetSubtreeCount(terminalSymbols, 0, 0); 146 157 … … 231 242 public void ConfigureAsDefaultRegressionGrammar() { 232 243 Symbols.First(s => s is Average).Enabled = false; 244 Symbols.First(s => s is Absolute).Enabled = false; 245 Symbols.First(s => s is HyperbolicTangent).Enabled = false; 233 246 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 234 247 Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false; … … 242 255 Symbols.First(s => s is VariableCondition).Enabled = false; 243 256 Symbols.First(s => s is Xor).Enabled = false; 257 Symbols.First(s => s is Absolute).Enabled = false; 258 Symbols.First(s => s is HyperbolicTangent).Enabled = false; 244 259 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 245 260 Symbols.First(s => s.Name == ExponentialFunctionsName).Enabled = false; … … 251 266 public void ConfigureAsDefaultTimeSeriesPrognosisGrammar() { 252 267 Symbols.First(s => s is Average).Enabled = false; 268 Symbols.First(s => s is Absolute).Enabled = false; 269 Symbols.First(s => s is HyperbolicTangent).Enabled = false; 253 270 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 254 271 Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
Note: See TracChangeset
for help on using the changeset viewer.