Changeset 17687 for branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
- Timestamp:
- 07/19/20 19:07:40 (4 years ago)
- Location:
- branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/1837_Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r10364 r17687 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-2013Heuristic 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(); … … 93 98 var or = new Or(); 94 99 var not = new Not(); 100 var xor = new Xor(); 95 101 var variableCondition = new VariableCondition(); 96 102 … … 103 109 constant.MaxValue = 20; 104 110 var variableSymbol = new Variable(); 111 var binFactorVariable = new BinaryFactorVariable(); 112 var factorVariable = new FactorVariable(); 105 113 var laggedVariable = new LaggedVariable(); 106 114 var autoregressiveVariable = new AutoregressiveTargetVariable(); … … 109 117 #region group symbol declaration 110 118 var arithmeticSymbols = new GroupSymbol(ArithmeticFunctionsName, new List<ISymbol>() { add, sub, mul, div, mean }); 111 var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan });119 var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan, tanh }); 112 120 var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log }); 113 var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { a iryA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi,114 fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral });115 var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, variableSymbol });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}); 123 var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, variableSymbol, binFactorVariable, factorVariable }); 116 124 var realValuedSymbols = new GroupSymbol(RealValuedSymbolsName, new List<ISymbol>() { arithmeticSymbols, trigonometricSymbols, exponentialAndLogarithmicSymbols, specialFunctions, terminalSymbols }); 117 125 118 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 }); 119 127 120 128 var conditionSymbols = new GroupSymbol(ConditionsName, new List<ISymbol> { @if, variableCondition }); 121 129 var comparisonSymbols = new GroupSymbol(ComparisonsName, new List<ISymbol> { gt, lt }); 122 var booleanOperationSymbols = new GroupSymbol(BooleanOperatorsName, new List<ISymbol> { and, or, not });130 var booleanOperationSymbols = new GroupSymbol(BooleanOperatorsName, new List<ISymbol> { and, or, not, xor }); 123 131 var conditionalSymbols = new GroupSymbol(ConditionalSymbolsName, new List<ISymbol> { conditionSymbols, comparisonSymbols, booleanOperationSymbols }); 124 132 … … 137 145 SetSubtreeCount(root, 2, 2); 138 146 SetSubtreeCount(square, 1, 1); 147 SetSubtreeCount(cube, 1, 1); 139 148 SetSubtreeCount(sqrt, 1, 1); 149 SetSubtreeCount(cubeRoot, 1, 1); 140 150 SetSubtreeCount(exponentialAndLogarithmicSymbols, 1, 1); 141 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 142 156 SetSubtreeCount(terminalSymbols, 0, 0); 143 157 … … 148 162 SetSubtreeCount(or, 2, 2); 149 163 SetSubtreeCount(not, 1, 1); 164 SetSubtreeCount(xor, 2, 2); 150 165 151 166 SetSubtreeCount(timeLag, 1, 1); … … 227 242 public void ConfigureAsDefaultRegressionGrammar() { 228 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; 229 246 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 230 247 Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false; … … 237 254 Symbols.First(s => s is Average).Enabled = false; 238 255 Symbols.First(s => s is VariableCondition).Enabled = false; 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; 239 259 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 240 260 Symbols.First(s => s.Name == ExponentialFunctionsName).Enabled = false; … … 246 266 public void ConfigureAsDefaultTimeSeriesPrognosisGrammar() { 247 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; 248 270 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 249 271 Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false;
Note: See TracChangeset
for help on using the changeset viewer.