Changeset 7696
- Timestamp:
- 04/03/12 08:20:22 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 15 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r7695 r7696 122 122 } else if (node.Symbol is Tangent) { 123 123 strBuilder.Append(@"\tan \left( "); 124 } else if (node.Symbol is AiryA) { 125 strBuilder.Append(@"\operatorname{airy}_a \left( "); 126 } else if (node.Symbol is AiryB) { 127 strBuilder.Append(@"\operatorname{airy}_b \left( "); 128 } else if (node.Symbol is Bessel) { 129 strBuilder.Append(@"\operatorname{bessel}_1 \left( "); 130 } else if (node.Symbol is CosineIntegral) { 131 strBuilder.Append(@"\operatorname{cosInt} \left( "); 132 } else if (node.Symbol is Dawson) { 133 strBuilder.Append(@"\operatorname{dawson} \left( "); 134 } else if (node.Symbol is Erf) { 135 strBuilder.Append(@"\operatorname{erf} \left( "); 136 } else if (node.Symbol is ExponentialIntegralEi) { 137 strBuilder.Append(@"\operatorname{expInt}_i \left( "); 138 } else if (node.Symbol is FresnelCosineIntegral) { 139 strBuilder.Append(@"\operatorname{fresnel}_\operatorName{cosInt} \left( "); 140 } else if (node.Symbol is FresnelSineIntegral) { 141 strBuilder.Append(@"\operatorname{fresnel}_\operatorName{sinInt} \left( "); 142 } else if (node.Symbol is Gamma) { 143 strBuilder.Append(@"\Gamma \left( "); 144 } else if (node.Symbol is HyperbolicCosineIntegral) { 145 strBuilder.Append(@"\operatorname{hypCosInt} \left( "); 146 } else if (node.Symbol is HyperbolicSineIntegral) { 147 strBuilder.Append(@"\operatorname{hypSinInt} \left( "); 148 } else if (node.Symbol is Psi) { 149 strBuilder.Append(@"\operatorname{digamma} \left( "); 150 } else if (node.Symbol is SineIntegral) { 151 strBuilder.Append(@"\operatorname{sinInt} \left( "); 124 152 } else if (node.Symbol is GreaterThan) { 125 153 strBuilder.Append(@" \left( "); … … 223 251 } else if (node.Symbol is Tangent) { 224 252 throw new InvalidOperationException(); 253 } else if (node.Symbol is AiryA) { 254 throw new InvalidOperationException(); 255 } else if (node.Symbol is AiryB) { 256 throw new InvalidOperationException(); 257 } else if (node.Symbol is Bessel) { 258 throw new InvalidOperationException(); 259 } else if (node.Symbol is CosineIntegral) { 260 throw new InvalidOperationException(); 261 } else if (node.Symbol is Dawson) { 262 throw new InvalidOperationException(); 263 } else if (node.Symbol is Erf) { 264 throw new InvalidOperationException(); 265 } else if (node.Symbol is ExponentialIntegralEi) { 266 throw new InvalidOperationException(); 267 } else if (node.Symbol is FresnelCosineIntegral) { 268 throw new InvalidOperationException(); 269 } else if (node.Symbol is FresnelSineIntegral) { 270 throw new InvalidOperationException(); 271 } else if (node.Symbol is Gamma) { 272 throw new InvalidOperationException(); 273 } else if (node.Symbol is HyperbolicCosineIntegral) { 274 throw new InvalidOperationException(); 275 } else if (node.Symbol is HyperbolicSineIntegral) { 276 throw new InvalidOperationException(); 277 } else if (node.Symbol is Psi) { 278 throw new InvalidOperationException(); 279 } else if (node.Symbol is SineIntegral) { 280 throw new InvalidOperationException(); 225 281 } else if (node.Symbol is GreaterThan) { 226 282 strBuilder.Append(@" > "); … … 284 340 } else if (node.Symbol is Tangent) { 285 341 strBuilder.Append(@" \right) "); 342 } else if (node.Symbol is AiryA) { 343 strBuilder.Append(@" \right) "); 344 } else if (node.Symbol is AiryB) { 345 strBuilder.Append(@" \right) "); 346 } else if (node.Symbol is Bessel) { 347 strBuilder.Append(@" \right) "); 348 } else if (node.Symbol is CosineIntegral) { 349 strBuilder.Append(@" \right) "); 350 } else if (node.Symbol is Dawson) { 351 strBuilder.Append(@" \right) "); 352 } else if (node.Symbol is Erf) { 353 strBuilder.Append(@" \right) "); 354 } else if (node.Symbol is ExponentialIntegralEi) { 355 strBuilder.Append(@" \right) "); 356 } else if (node.Symbol is FresnelCosineIntegral) { 357 strBuilder.Append(@" \right) "); 358 } else if (node.Symbol is FresnelSineIntegral) { 359 strBuilder.Append(@" \right) "); 360 } else if (node.Symbol is Gamma) { 361 strBuilder.Append(@" \right) "); 362 } else if (node.Symbol is HyperbolicCosineIntegral) { 363 strBuilder.Append(@" \right) "); 364 } else if (node.Symbol is HyperbolicSineIntegral) { 365 strBuilder.Append(@" \right) "); 366 } else if (node.Symbol is Psi) { 367 strBuilder.Append(@" \right) "); 368 } else if (node.Symbol is SineIntegral) { 369 strBuilder.Append(@" \right) "); 286 370 } else if (node.Symbol is GreaterThan) { 287 371 strBuilder.Append(@" \right) "); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/FullFunctionalExpressionGrammar.cs
r7695 r7696 61 61 var sqrt = new SquareRoot(); 62 62 sqrt.InitialFrequency = 0.0; 63 var airyA = new AiryA(); 64 var airyB = new AiryB(); 65 var bessel = new Bessel(); 66 var cosineIntegral = new CosineIntegral(); 67 var dawson = new Dawson(); 68 var erf = new Erf(); 69 var expIntegralEi = new ExponentialIntegralEi(); 70 var fresnelCosineIntegral = new FresnelCosineIntegral(); 71 var fresnelSineIntegral = new FresnelSineIntegral(); 72 var gamma = new Gamma(); 73 var hypCosineIntegral = new HyperbolicCosineIntegral(); 74 var hypSineIntegral = new HyperbolicSineIntegral(); 75 var norm = new Norm(); 76 var psi = new Psi(); 77 var sineIntegral = new SineIntegral(); 78 63 79 var exp = new Exponential(); 64 80 var @if = new IfThenElse(); … … 86 102 laggedVariable.InitialFrequency = 0.0; 87 103 88 var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, square, pow, sqrt, root, exp, @if, gt, lt, and, or, not, timeLag, integral, derivative, constant, variableSymbol, laggedVariable, variableCondition }; 89 var unaryFunctionSymbols = new List<Symbol>() { square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative }; 104 var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, square, pow, sqrt, root, exp, 105 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral, 106 @if, gt, lt, and, or, not, timeLag, integral, derivative, constant, variableSymbol, laggedVariable, variableCondition }; 107 var unaryFunctionSymbols = new List<Symbol>() { square, sqrt, sin, cos, tan, log, exp, not, timeLag, integral, derivative, 108 airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, fresnelCosineIntegral, fresnelSineIntegral, gamma, hypCosineIntegral, hypSineIntegral, norm, psi, sineIntegral 109 }; 90 110 91 111 var binaryFunctionSymbols = new List<Symbol>() { pow, root, gt, lt, variableCondition }; 92 var functionSymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or };112 var ternarySymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or }; 93 113 var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable }; 94 114 … … 96 116 AddSymbol(symb); 97 117 98 foreach (var funSymb in functionSymbols) {118 foreach (var funSymb in ternarySymbols) { 99 119 SetSubtreeCount(funSymb, 1, 3); 100 120 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/TypeCoherentExpressionGrammar.cs
r7695 r7696 40 40 private const string BooleanOperatorsName = "Boolean Operators"; 41 41 private const string ConditionalSymbolsName = "ConditionalSymbols"; 42 private const string SpecialFunctionsName = "Special Functions"; 42 43 private const string TimeSeriesSymbolsName = "Time Series Symbols"; 43 44 … … 69 70 var sqrt = new SquareRoot(); 70 71 var exp = new Exponential(); 72 73 var airyA = new AiryA(); 74 var airyB = new AiryB(); 75 var bessel = new Bessel(); 76 var cosineIntegral = new CosineIntegral(); 77 var dawson = new Dawson(); 78 var erf = new Erf(); 79 var expIntegralEi = new ExponentialIntegralEi(); 80 var fresnelCosineIntegral = new FresnelCosineIntegral(); 81 var fresnelSineIntegral = new FresnelSineIntegral(); 82 var gamma = new Gamma(); 83 var hypCosineIntegral = new HyperbolicCosineIntegral(); 84 var hypSineIntegral = new HyperbolicSineIntegral(); 85 var norm = new Norm(); 86 var psi = new Psi(); 87 var sineIntegral = new SineIntegral(); 88 71 89 var @if = new IfThenElse(); 72 90 var gt = new GreaterThan(); … … 92 110 var trigonometricSymbols = new GroupSymbol(TrigonometricFunctionsName, new List<ISymbol>() { sin, cos, tan }); 93 111 var exponentialAndLogarithmicSymbols = new GroupSymbol(ExponentialFunctionsName, new List<ISymbol> { exp, log }); 112 var specialFunctions = new GroupSymbol(SpecialFunctionsName, new List<ISymbol> { airyA, airyB, bessel, cosineIntegral, dawson, erf, expIntegralEi, 113 fresnelCosineIntegral,fresnelSineIntegral,gamma,hypCosineIntegral,hypSineIntegral,norm, psi, sineIntegral}); 94 114 var terminalSymbols = new GroupSymbol(TerminalsName, new List<ISymbol> { constant, variableSymbol }); 95 var realValuedSymbols = new GroupSymbol(RealValuedSymbolsName, new List<ISymbol>() { arithmeticSymbols, trigonometricSymbols, exponentialAndLogarithmicSymbols, terminalSymbols });115 var realValuedSymbols = new GroupSymbol(RealValuedSymbolsName, new List<ISymbol>() { arithmeticSymbols, trigonometricSymbols, exponentialAndLogarithmicSymbols, specialFunctions, terminalSymbols }); 96 116 97 117 var powerSymbols = new GroupSymbol(PowerFunctionsName, new List<ISymbol> { square, pow, sqrt, root }); … … 118 138 SetSubtreeCount(sqrt, 1, 1); 119 139 SetSubtreeCount(exponentialAndLogarithmicSymbols, 1, 1); 140 SetSubtreeCount(specialFunctions, 1, 1); 120 141 SetSubtreeCount(terminalSymbols, 0, 0); 121 142 … … 141 162 AddAllowedChildSymbol(realValuedSymbols, conditionSymbols); 142 163 AddAllowedChildSymbol(realValuedSymbols, timeSeriesSymbols); 164 AddAllowedChildSymbol(realValuedSymbols, specialFunctions); 143 165 144 166 AddAllowedChildSymbol(powerSymbols, variableSymbol, 0); … … 186 208 187 209 public void ConfigureAsDefaultRegressionGrammar() { 188 Symbols.Where(s => s is Average).First().Enabled = false; 189 Symbols.Where(s => s.Name == TrigonometricFunctionsName).First().Enabled = false; 190 Symbols.Where(s => s.Name == PowerFunctionsName).First().Enabled = false; 191 Symbols.Where(s => s.Name == ConditionalSymbolsName).First().Enabled = false; 192 Symbols.Where(s => s.Name == TimeSeriesSymbolsName).First().Enabled = false; 210 Symbols.First(s => s is Average).Enabled = false; 211 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 212 Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false; 213 Symbols.First(s => s.Name == SpecialFunctionsName).Enabled = false; 214 Symbols.First(s => s.Name == ConditionalSymbolsName).Enabled = false; 215 Symbols.First(s => s.Name == TimeSeriesSymbolsName).Enabled = false; 193 216 } 194 217 195 218 public void ConfigureAsDefaultClassificationGrammar() { 196 Symbols.Where(s => s is Average).First().Enabled = false; 197 Symbols.Where(s => s is VariableCondition).First().Enabled = false; 198 Symbols.Where(s => s.Name == TrigonometricFunctionsName).First().Enabled = false; 199 Symbols.Where(s => s.Name == ExponentialFunctionsName).First().Enabled = false; 200 Symbols.Where(s => s.Name == PowerFunctionsName).First().Enabled = false; 201 Symbols.Where(s => s.Name == TimeSeriesSymbolsName).First().Enabled = false; 219 Symbols.First(s => s is Average).Enabled = false; 220 Symbols.First(s => s is VariableCondition).Enabled = false; 221 Symbols.First(s => s.Name == TrigonometricFunctionsName).Enabled = false; 222 Symbols.First(s => s.Name == ExponentialFunctionsName).Enabled = false; 223 Symbols.First(s => s.Name == SpecialFunctionsName).Enabled = false; 224 Symbols.First(s => s.Name == PowerFunctionsName).Enabled = false; 225 Symbols.First(s => s.Name == TimeSeriesSymbolsName).Enabled = false; 202 226 } 203 227 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r7695 r7696 93 93 </PropertyGroup> 94 94 <ItemGroup> 95 <Reference Include="ALGLIB-3.5.0, Version=3.5.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 96 <HintPath>..\..\bin\ALGLIB-3.5.0.dll</HintPath> 97 </Reference> 95 98 <Reference Include="System" /> 96 99 <Reference Include="System.Core"> … … 161 164 <Compile Include="Symbols\Constant.cs" /> 162 165 <Compile Include="Symbols\ConstantTreeNode.cs" /> 166 <Compile Include="Symbols\AiryA.cs" /> 167 <Compile Include="Symbols\AiryB.cs" /> 168 <Compile Include="Symbols\Bessel.cs" /> 169 <Compile Include="Symbols\Erf.cs" /> 170 <Compile Include="Symbols\Norm.cs" /> 171 <Compile Include="Symbols\FresnelCosineIntegral.cs" /> 172 <Compile Include="Symbols\FresnelSineIntegral.cs" /> 173 <Compile Include="Symbols\HyperbolicSineIntegral.cs" /> 174 <Compile Include="Symbols\HyperbolicCosineIntegral.cs" /> 175 <Compile Include="Symbols\SineIntegral.cs" /> 176 <Compile Include="Symbols\CosineIntegral.cs" /> 177 <Compile Include="Symbols\ExponentialIntegralEi.cs" /> 178 <Compile Include="Symbols\Dawson.cs" /> 179 <Compile Include="Symbols\Psi.cs" /> 180 <Compile Include="Symbols\Gamma.cs" /> 163 181 <Compile Include="Symbols\SquareRoot.cs" /> 164 182 <Compile Include="Symbols\Square.cs" /> -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame
r7259 r7696 28 28 [Plugin("HeuristicLab.Problems.DataAnalysis.Symbolic","Provides base classes for symbolic data analysis tasks.", "3.4.2.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll", PluginFileType.Assembly)] 30 [PluginDependency("HeuristicLab.ALGLIB", "3.5.0")] 30 31 [PluginDependency("HeuristicLab.Analysis", "3.3")] 31 32 [PluginDependency("HeuristicLab.Collections", "3.3")] -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r7695 r7696 136 136 public const byte Square = 28; 137 137 public const byte SquareRoot = 29; 138 public const byte Gamma = 30; 139 public const byte Psi = 31; 140 public const byte Dawson = 32; 141 public const byte ExponentialIntegralEi = 33; 142 public const byte CosineIntegral = 34; 143 public const byte SineIntegral = 35; 144 public const byte HyperbolicCosineIntegral = 36; 145 public const byte HyperbolicSineIntegral = 37; 146 public const byte FresnelCosineIntegral = 38; 147 public const byte FresnelSineIntegral = 39; 148 public const byte AiryA = 40; 149 public const byte AiryB = 41; 150 public const byte Norm = 42; 151 public const byte Erf = 43; 152 public const byte Bessel = 44; 138 153 } 139 154 #endregion … … 168 183 { typeof(VariableCondition),OpCodes.VariableCondition}, 169 184 { typeof(Square),OpCodes.Square}, 170 {typeof(SquareRoot),OpCodes.SquareRoot} 185 { typeof(SquareRoot),OpCodes.SquareRoot}, 186 { typeof(Gamma), OpCodes.Gamma }, 187 { typeof(Psi), OpCodes.Psi }, 188 { typeof(Dawson), OpCodes.Dawson}, 189 { typeof(ExponentialIntegralEi), OpCodes.ExponentialIntegralEi }, 190 { typeof(CosineIntegral), OpCodes.CosineIntegral }, 191 { typeof(SineIntegral), OpCodes.SineIntegral }, 192 { typeof(HyperbolicCosineIntegral), OpCodes.HyperbolicCosineIntegral }, 193 { typeof(HyperbolicSineIntegral), OpCodes.HyperbolicSineIntegral }, 194 { typeof(FresnelCosineIntegral), OpCodes.FresnelCosineIntegral }, 195 { typeof(FresnelSineIntegral), OpCodes.FresnelSineIntegral }, 196 { typeof(AiryA), OpCodes.AiryA }, 197 { typeof(AiryB), OpCodes.AiryB }, 198 { typeof(Norm), OpCodes.Norm}, 199 { typeof(Erf), OpCodes.Erf}, 200 { typeof(Bessel), OpCodes.Bessel} 171 201 }; 172 202 … … 332 362 return Math.Log(Evaluate(dataset, ref row, state)); 333 363 } 364 case OpCodes.Gamma: { 365 var x = Evaluate(dataset, ref row, state); 366 if (double.IsNaN(x)) return double.NaN; 367 else return alglib.gammafunction(x); 368 } 369 case OpCodes.Psi: { 370 var x = Evaluate(dataset, ref row, state); 371 if (double.IsNaN(x)) return double.NaN; 372 else if (x.IsAlmost(0.0)) return 0.0; 373 else if (x.IsAlmost(-1.0)) return 0.0; 374 return alglib.psi(x); 375 } 376 case OpCodes.Dawson: { 377 var x = Evaluate(dataset, ref row, state); 378 if (double.IsNaN(x)) return double.NaN; 379 return alglib.dawsonintegral(x); 380 } 381 case OpCodes.ExponentialIntegralEi: { 382 var x = Evaluate(dataset, ref row, state); 383 if (double.IsNaN(x)) return double.NaN; 384 return alglib.exponentialintegralei(x); 385 } 386 case OpCodes.SineIntegral: { 387 double si, ci; 388 var x = Evaluate(dataset, ref row, state); 389 if (double.IsNaN(x)) return double.NaN; 390 else { 391 alglib.sinecosineintegrals(x, out si, out ci); 392 return si; 393 } 394 } 395 case OpCodes.CosineIntegral: { 396 double si, ci; 397 var x = Evaluate(dataset, ref row, state); 398 if (double.IsNaN(x)) return double.NaN; 399 else { 400 alglib.sinecosineintegrals(x, out si, out ci); 401 return ci; 402 } 403 } 404 case OpCodes.HyperbolicSineIntegral: { 405 double shi, chi; 406 var x = Evaluate(dataset, ref row, state); 407 if (double.IsNaN(x)) return double.NaN; 408 else { 409 alglib.hyperbolicsinecosineintegrals(x, out shi, out chi); 410 return shi; 411 } 412 } 413 case OpCodes.HyperbolicCosineIntegral: { 414 double shi, chi; 415 var x = Evaluate(dataset, ref row, state); 416 if (double.IsNaN(x)) return double.NaN; 417 else { 418 alglib.hyperbolicsinecosineintegrals(x, out shi, out chi); 419 return chi; 420 } 421 } 422 case OpCodes.FresnelCosineIntegral: { 423 double c = 0, s = 0; 424 var x = Evaluate(dataset, ref row, state); 425 if (double.IsNaN(x)) return double.NaN; 426 else { 427 alglib.fresnelintegral(x, ref c, ref s); 428 return c; 429 } 430 } 431 case OpCodes.FresnelSineIntegral: { 432 double c = 0, s = 0; 433 var x = Evaluate(dataset, ref row, state); 434 if (double.IsNaN(x)) return double.NaN; 435 else { 436 alglib.fresnelintegral(x, ref c, ref s); 437 return s; 438 } 439 } 440 case OpCodes.AiryA: { 441 double ai, aip, bi, bip; 442 var x = Evaluate(dataset, ref row, state); 443 if (double.IsNaN(x)) return double.NaN; 444 else { 445 alglib.airy(x, out ai, out aip, out bi, out bip); 446 return ai; 447 } 448 } 449 case OpCodes.AiryB: { 450 double ai, aip, bi, bip; 451 var x = Evaluate(dataset, ref row, state); 452 if (double.IsNaN(x)) return double.NaN; 453 else { 454 alglib.airy(x, out ai, out aip, out bi, out bip); 455 return bi; 456 } 457 } 458 case OpCodes.Norm: { 459 var x = Evaluate(dataset, ref row, state); 460 if (double.IsNaN(x)) return double.NaN; 461 else return alglib.normaldistribution(x); 462 } 463 case OpCodes.Erf: { 464 var x = Evaluate(dataset, ref row, state); 465 if (double.IsNaN(x)) return double.NaN; 466 else return alglib.errorfunction(x); 467 } 468 case OpCodes.Bessel: { 469 var x = Evaluate(dataset, ref row, state); 470 if (double.IsNaN(x)) return double.NaN; 471 else return alglib.besseli0(x); 472 } 334 473 case OpCodes.IfThenElse: { 335 474 double condition = Evaluate(dataset, ref row, state); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
r7695 r7696 581 581 } else if (IsExp(node)) { 582 582 return node.GetSubtree(0); 583 } else if (IsSquareRoot(node)) { 584 return MakeFraction(MakeLog(node.GetSubtree(0)), MakeConstant(2.0)); 583 585 } else { 584 586 var logNode = logSymbol.CreateTreeNode();
Note: See TracChangeset
for help on using the changeset viewer.