- Timestamp:
- 09/20/11 17:45:14 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
r6770 r6809 247 247 248 248 ILGenerator il = testFun.GetILGenerator(); 249 CompileInstructions(il, state );249 CompileInstructions(il, state, dataset); 250 250 il.Emit(System.Reflection.Emit.OpCodes.Conv_R8); 251 251 il.Emit(System.Reflection.Emit.OpCodes.Ret); … … 257 257 } 258 258 259 private void CompileInstructions(ILGenerator il, InterpreterState state ) {259 private void CompileInstructions(ILGenerator il, InterpreterState state, Dataset ds) { 260 260 Instruction currentInstr = state.NextInstruction(); 261 261 int nArgs = currentInstr.nArguments; … … 264 264 case OpCodes.Add: { 265 265 if (nArgs > 0) { 266 CompileInstructions(il, state );266 CompileInstructions(il, state, ds); 267 267 } 268 268 for (int i = 1; i < nArgs; i++) { 269 CompileInstructions(il, state );269 CompileInstructions(il, state, ds); 270 270 il.Emit(System.Reflection.Emit.OpCodes.Add); 271 271 } … … 274 274 case OpCodes.Sub: { 275 275 if (nArgs == 1) { 276 CompileInstructions(il, state );276 CompileInstructions(il, state, ds); 277 277 il.Emit(System.Reflection.Emit.OpCodes.Neg); 278 278 return; 279 279 } 280 280 if (nArgs > 0) { 281 CompileInstructions(il, state );281 CompileInstructions(il, state, ds); 282 282 } 283 283 for (int i = 1; i < nArgs; i++) { 284 CompileInstructions(il, state );284 CompileInstructions(il, state, ds); 285 285 il.Emit(System.Reflection.Emit.OpCodes.Sub); 286 286 } … … 289 289 case OpCodes.Mul: { 290 290 if (nArgs > 0) { 291 CompileInstructions(il, state );291 CompileInstructions(il, state, ds); 292 292 } 293 293 for (int i = 1; i < nArgs; i++) { 294 CompileInstructions(il, state );294 CompileInstructions(il, state, ds); 295 295 il.Emit(System.Reflection.Emit.OpCodes.Mul); 296 296 } … … 300 300 if (nArgs == 1) { 301 301 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 1.0); 302 CompileInstructions(il, state );302 CompileInstructions(il, state, ds); 303 303 il.Emit(System.Reflection.Emit.OpCodes.Div); 304 304 return; 305 305 } 306 306 if (nArgs > 0) { 307 CompileInstructions(il, state );307 CompileInstructions(il, state, ds); 308 308 } 309 309 for (int i = 1; i < nArgs; i++) { 310 CompileInstructions(il, state );310 CompileInstructions(il, state, ds); 311 311 il.Emit(System.Reflection.Emit.OpCodes.Div); 312 312 } … … 314 314 } 315 315 case OpCodes.Average: { 316 CompileInstructions(il, state );316 CompileInstructions(il, state, ds); 317 317 for (int i = 1; i < nArgs; i++) { 318 CompileInstructions(il, state );318 CompileInstructions(il, state, ds); 319 319 il.Emit(System.Reflection.Emit.OpCodes.Add); 320 320 } … … 324 324 } 325 325 case OpCodes.Cos: { 326 CompileInstructions(il, state );326 CompileInstructions(il, state, ds); 327 327 il.Emit(System.Reflection.Emit.OpCodes.Call, cos); 328 328 return; 329 329 } 330 330 case OpCodes.Sin: { 331 CompileInstructions(il, state );331 CompileInstructions(il, state, ds); 332 332 il.Emit(System.Reflection.Emit.OpCodes.Call, sin); 333 333 return; 334 334 } 335 335 case OpCodes.Tan: { 336 CompileInstructions(il, state );336 CompileInstructions(il, state, ds); 337 337 il.Emit(System.Reflection.Emit.OpCodes.Call, tan); 338 338 return; 339 339 } 340 340 case OpCodes.Power: { 341 CompileInstructions(il, state );342 CompileInstructions(il, state );341 CompileInstructions(il, state, ds); 342 CompileInstructions(il, state, ds); 343 343 il.Emit(System.Reflection.Emit.OpCodes.Call, round); 344 344 il.Emit(System.Reflection.Emit.OpCodes.Call, power); … … 346 346 } 347 347 case OpCodes.Root: { 348 CompileInstructions(il, state );348 CompileInstructions(il, state, ds); 349 349 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 1.0); // 1 / round(...) 350 CompileInstructions(il, state );350 CompileInstructions(il, state, ds); 351 351 il.Emit(System.Reflection.Emit.OpCodes.Call, round); 352 352 il.Emit(System.Reflection.Emit.OpCodes.Div); … … 355 355 } 356 356 case OpCodes.Exp: { 357 CompileInstructions(il, state );357 CompileInstructions(il, state, ds); 358 358 il.Emit(System.Reflection.Emit.OpCodes.Call, exp); 359 359 return; 360 360 } 361 361 case OpCodes.Log: { 362 CompileInstructions(il, state );362 CompileInstructions(il, state, ds); 363 363 il.Emit(System.Reflection.Emit.OpCodes.Call, log); 364 364 return; … … 367 367 Label end = il.DefineLabel(); 368 368 Label c1 = il.DefineLabel(); 369 CompileInstructions(il, state );369 CompileInstructions(il, state, ds); 370 370 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // > 0 371 371 il.Emit(System.Reflection.Emit.OpCodes.Cgt); 372 372 il.Emit(System.Reflection.Emit.OpCodes.Brfalse, c1); 373 CompileInstructions(il, state );373 CompileInstructions(il, state, ds); 374 374 il.Emit(System.Reflection.Emit.OpCodes.Br, end); 375 375 il.MarkLabel(c1); 376 CompileInstructions(il, state );376 CompileInstructions(il, state, ds); 377 377 il.MarkLabel(end); 378 378 return; … … 381 381 Label falseBranch = il.DefineLabel(); 382 382 Label end = il.DefineLabel(); 383 CompileInstructions(il, state );383 CompileInstructions(il, state, ds); 384 384 for (int i = 1; i < nArgs; i++) { 385 385 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // > 0 386 386 il.Emit(System.Reflection.Emit.OpCodes.Cgt); 387 387 il.Emit(System.Reflection.Emit.OpCodes.Brfalse, falseBranch); 388 CompileInstructions(il, state );388 CompileInstructions(il, state, ds); 389 389 } 390 390 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // > 0 … … 403 403 Label end = il.DefineLabel(); 404 404 Label resultBranch = il.DefineLabel(); 405 CompileInstructions(il, state );405 CompileInstructions(il, state, ds); 406 406 for (int i = 1; i < nArgs; i++) { 407 407 Label nextArgBranch = il.DefineLabel(); … … 413 413 il.MarkLabel(nextArgBranch); 414 414 il.Emit(System.Reflection.Emit.OpCodes.Pop); 415 CompileInstructions(il, state );415 CompileInstructions(il, state, ds); 416 416 } 417 417 il.MarkLabel(resultBranch); … … 428 428 } 429 429 case OpCodes.NOT: { 430 CompileInstructions(il, state );430 CompileInstructions(il, state, ds); 431 431 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); // > 0 432 432 il.Emit(System.Reflection.Emit.OpCodes.Cgt); … … 439 439 } 440 440 case OpCodes.GT: { 441 CompileInstructions(il, state); 442 CompileInstructions(il, state); 441 CompileInstructions(il, state, ds); 442 CompileInstructions(il, state, ds); 443 443 444 il.Emit(System.Reflection.Emit.OpCodes.Cgt); // 1 (>) / 0 (otherwise) 444 445 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 2.0); // * 2 … … 449 450 } 450 451 case OpCodes.LT: { 451 CompileInstructions(il, state );452 CompileInstructions(il, state );452 CompileInstructions(il, state, ds); 453 CompileInstructions(il, state, ds); 453 454 il.Emit(System.Reflection.Emit.OpCodes.Clt); 454 455 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 2.0); // * 2 … … 459 460 } 460 461 case OpCodes.TimeLag: { 461 throw new NotImplementedException(); 462 LaggedTreeNode laggedTreeNode = (LaggedTreeNode)currentInstr.dynamicNode; 463 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // row -= lag 464 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, laggedTreeNode.Lag); 465 il.Emit(System.Reflection.Emit.OpCodes.Add); 466 il.Emit(System.Reflection.Emit.OpCodes.Starg, 0); 467 CompileInstructions(il, state, ds); 468 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // row += lag 469 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, laggedTreeNode.Lag); 470 il.Emit(System.Reflection.Emit.OpCodes.Sub); 471 il.Emit(System.Reflection.Emit.OpCodes.Starg, 0); 472 return; 462 473 } 463 474 case OpCodes.Integral: { 464 throw new NotImplementedException(); 475 int savedPc = state.ProgramCounter; 476 LaggedTreeNode laggedTreeNode = (LaggedTreeNode)currentInstr.dynamicNode; 477 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // row -= lag 478 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, laggedTreeNode.Lag); 479 il.Emit(System.Reflection.Emit.OpCodes.Add); 480 il.Emit(System.Reflection.Emit.OpCodes.Starg, 0); 481 CompileInstructions(il, state, ds); 482 for (int l = laggedTreeNode.Lag; l < 0; l++) { 483 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // row += lag 484 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_1); 485 il.Emit(System.Reflection.Emit.OpCodes.Add); 486 il.Emit(System.Reflection.Emit.OpCodes.Starg, 0); 487 state.ProgramCounter = savedPc; 488 CompileInstructions(il, state, ds); 489 il.Emit(System.Reflection.Emit.OpCodes.Add); 490 } 491 return; 465 492 } 466 493 … … 470 497 // y' = 1/8h (f_i + 2f_i-1, -2 f_i-3 - f_i-4) 471 498 case OpCodes.Derivative: { 472 throw new NotImplementedException(); 499 int savedPc = state.ProgramCounter; 500 CompileInstructions(il, state, ds); 501 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // row -- 502 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_M1); 503 il.Emit(System.Reflection.Emit.OpCodes.Add); 504 il.Emit(System.Reflection.Emit.OpCodes.Starg, 0); 505 state.ProgramCounter = savedPc; 506 CompileInstructions(il, state, ds); 507 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 2.0); // f_0 + 2 * f_1 508 il.Emit(System.Reflection.Emit.OpCodes.Mul); 509 il.Emit(System.Reflection.Emit.OpCodes.Add); 510 511 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // row -=2 512 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_2); 513 il.Emit(System.Reflection.Emit.OpCodes.Sub); 514 il.Emit(System.Reflection.Emit.OpCodes.Starg, 0); 515 state.ProgramCounter = savedPc; 516 CompileInstructions(il, state, ds); 517 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 2.0); // f_0 + 2 * f_1 - 2 * f_3 518 il.Emit(System.Reflection.Emit.OpCodes.Mul); 519 il.Emit(System.Reflection.Emit.OpCodes.Sub); 520 521 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // row -- 522 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_M1); 523 il.Emit(System.Reflection.Emit.OpCodes.Add); 524 il.Emit(System.Reflection.Emit.OpCodes.Starg, 0); 525 state.ProgramCounter = savedPc; 526 CompileInstructions(il, state, ds); 527 il.Emit(System.Reflection.Emit.OpCodes.Sub); // f_0 + 2 * f_1 - 2 * f_3 - f_4 528 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, 8.0); // / 8 529 il.Emit(System.Reflection.Emit.OpCodes.Div); 530 531 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // row +=4 532 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_4); 533 il.Emit(System.Reflection.Emit.OpCodes.Add); 534 il.Emit(System.Reflection.Emit.OpCodes.Starg, 0); 535 return; 473 536 } 474 537 case OpCodes.Call: { … … 479 542 } 480 543 case OpCodes.Variable: { 544 var nanResult = il.DefineLabel(); 545 var normalResult = il.DefineLabel(); 481 546 VariableTreeNode varNode = (VariableTreeNode)currentInstr.dynamicNode; 482 547 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array … … 484 549 il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref); 485 550 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // sampleIndex 551 il.Emit(System.Reflection.Emit.OpCodes.Dup); 552 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); 553 il.Emit(System.Reflection.Emit.OpCodes.Blt, nanResult); 554 il.Emit(System.Reflection.Emit.OpCodes.Dup); 555 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, ds.Rows); 556 il.Emit(System.Reflection.Emit.OpCodes.Bge, nanResult); 486 557 il.Emit(System.Reflection.Emit.OpCodes.Call, listGetValue); 487 558 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, varNode.Weight); // load weight 488 559 il.Emit(System.Reflection.Emit.OpCodes.Mul); 560 il.Emit(System.Reflection.Emit.OpCodes.Br, normalResult); 561 il.MarkLabel(nanResult); 562 il.Emit(System.Reflection.Emit.OpCodes.Pop); // sample index 563 il.Emit(System.Reflection.Emit.OpCodes.Pop); // column reference 564 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, double.NaN); 565 il.MarkLabel(normalResult); 489 566 return; 490 567 } 491 568 case OpCodes.LagVariable: { 569 var nanResult = il.DefineLabel(); 570 var normalResult = il.DefineLabel(); 492 571 LaggedVariableTreeNode varNode = (LaggedVariableTreeNode)currentInstr.dynamicNode; 493 572 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array … … 497 576 il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // sampleIndex 498 577 il.Emit(System.Reflection.Emit.OpCodes.Add); // row = sampleIndex + sampleOffset 578 il.Emit(System.Reflection.Emit.OpCodes.Dup); 579 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0); 580 il.Emit(System.Reflection.Emit.OpCodes.Blt, nanResult); 581 il.Emit(System.Reflection.Emit.OpCodes.Dup); 582 il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, ds.Rows); 583 il.Emit(System.Reflection.Emit.OpCodes.Bge, nanResult); 499 584 il.Emit(System.Reflection.Emit.OpCodes.Call, listGetValue); 500 585 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, varNode.Weight); // load weight 501 586 il.Emit(System.Reflection.Emit.OpCodes.Mul); 587 il.Emit(System.Reflection.Emit.OpCodes.Br, normalResult); 588 il.MarkLabel(nanResult); 589 il.Emit(System.Reflection.Emit.OpCodes.Pop); // sample index 590 il.Emit(System.Reflection.Emit.OpCodes.Pop); // column reference 591 il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, double.NaN); 592 il.MarkLabel(normalResult); 502 593 return; 503 594 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/TimeLag.cs
r6803 r6809 43 43 public override IDeepCloneable Clone(Cloner cloner) { return new TimeLag(this, cloner); } 44 44 45 public TimeLag() : base("TimeLag", "Represents a symb lol whose evaluation is shifted.") { }45 public TimeLag() : base("TimeLag", "Represents a symbol whose evaluation is shifted.") { } 46 46 } 47 47 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tests/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs
r6769 r6809 110 110 { 1.0, 1.0, 1.0 }, 111 111 { 2.0, 2.0, 2.0 }, 112 { 3.0, 1.0, 2.0 } 112 { 3.0, 1.0, 2.0 }, 113 { 4.0, 1.0, 1.0 }, 114 { 5.0, 2.0, 2.0 }, 115 { 6.0, 1.0, 2.0 }, 116 { 7.0, 1.0, 1.0 }, 117 { 8.0, 2.0, 2.0 }, 118 { 9.0, 1.0, 2.0 }, 119 { 10.0, 1.0, 1.0 }, 120 { 11.0, 2.0, 2.0 }, 121 { 12.0, 1.0, 2.0 } 113 122 }); 114 123 … … 124 133 { 1.0, 1.0, 1.0 }, 125 134 { 2.0, 2.0, 2.0 }, 126 { 3.0, 1.0, 2.0 } 135 { 3.0, 1.0, 2.0 }, 136 { 4.0, 1.0, 1.0 }, 137 { 5.0, 2.0, 2.0 }, 138 { 6.0, 1.0, 2.0 }, 139 { 7.0, 1.0, 1.0 }, 140 { 8.0, 2.0, 2.0 }, 141 { 9.0, 1.0, 2.0 }, 142 { 10.0, 1.0, 1.0 }, 143 { 11.0, 2.0, 2.0 }, 144 { 12.0, 1.0, 2.0 } 127 145 }); 128 146 … … 297 315 Evaluate(interpreter, ds, "(lagVariable 1.0 a 0) ", 2, ds.GetDoubleValue("A", 2)); 298 316 Evaluate(interpreter, ds, "(lagVariable 1.0 a 1) ", 0, ds.GetDoubleValue("A", 1)); 317 318 // integral 319 Evaluate(interpreter, ds, "(integral -1.0 (variable 1.0 a)) ", 1, ds.GetDoubleValue("A", 0) + ds.GetDoubleValue("A", 1)); 320 Evaluate(interpreter, ds, "(integral -1.0 (lagVariable 1.0 a 1)) ", 1, ds.GetDoubleValue("A", 1) + ds.GetDoubleValue("A", 2)); 321 Evaluate(interpreter, ds, "(integral -2.0 (variable 1.0 a)) ", 2, ds.GetDoubleValue("A", 0) + ds.GetDoubleValue("A", 1) + ds.GetDoubleValue("A", 2)); 322 Evaluate(interpreter, ds, "(integral -1.0 (* (variable 1.0 a) (variable 1.0 b)))", 1, ds.GetDoubleValue("A", 0) * ds.GetDoubleValue("B", 0) + ds.GetDoubleValue("A", 1) * ds.GetDoubleValue("B", 1)); 323 Evaluate(interpreter, ds, "(integral -2.0 3.0)", 1, 9.0); 324 325 // derivative 326 // (f_0 + 2 * f_1 - 2 * f_3 - f_4) / 8; // h = 1 327 Evaluate(interpreter, ds, "(diff (variable 1.0 a)) ", 5, (ds.GetDoubleValue("A", 5) + 2 * ds.GetDoubleValue("A", 4) - 2 * ds.GetDoubleValue("A", 2) - ds.GetDoubleValue("A", 1)) / 8.0); 328 Evaluate(interpreter, ds, "(diff (variable 1.0 b)) ", 5, (ds.GetDoubleValue("B", 5) + 2 * ds.GetDoubleValue("B", 4) - 2 * ds.GetDoubleValue("B", 2) - ds.GetDoubleValue("B", 1)) / 8.0); 329 Evaluate(interpreter, ds, "(diff (* (variable 1.0 a) (variable 1.0 b)))", 5, + 330 (ds.GetDoubleValue("A", 5) * ds.GetDoubleValue("B", 5) + 331 2 * ds.GetDoubleValue("A", 4) * ds.GetDoubleValue("B", 4) - 332 2 * ds.GetDoubleValue("A", 2) * ds.GetDoubleValue("B", 2) - 333 ds.GetDoubleValue("A", 1) * ds.GetDoubleValue("B", 1)) / 8.0); 334 Evaluate(interpreter, ds, "(diff -2.0 3.0)", 5, 0.0); 335 336 // timelag 337 Evaluate(interpreter, ds, "(lag -1.0 (lagVariable 1.0 a 2)) ", 1, ds.GetDoubleValue("A", 2)); 338 Evaluate(interpreter, ds, "(lag -2.0 (lagVariable 1.0 a 2)) ", 2, ds.GetDoubleValue("A", 2)); 339 Evaluate(interpreter, ds, "(lag -1.0 (* (lagVariable 1.0 a 1) (lagVariable 1.0 b 2)))", 1, ds.GetDoubleValue("A", 1) * ds.GetDoubleValue("B", 2)); 340 Evaluate(interpreter, ds, "(lag -2.0 3.0)", 1, 3.0); 299 341 } 300 342 … … 305 347 double actual = interpreter.GetSymbolicExpressionTreeValues(tree, ds, Enumerable.Range(index, 1)).First(); 306 348 349 Assert.IsFalse(double.IsNaN(actual) && !double.IsNaN(expected)); 350 Assert.IsFalse(!double.IsNaN(actual) && double.IsNaN(expected)); 307 351 Assert.AreEqual(expected, actual, 1.0E-12, expr); 308 352 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tests/SymbolicExpressionImporter.cs
r6769 r6809 29 29 internal class SymbolicExpressionImporter { 30 30 private const string VARSTART = "VAR"; 31 private const string LAGGEDVARSTART = "LAG"; 31 private const string LAGGEDVARSTART = "LAGVARIABLE"; 32 private const string INTEGRALSTART = "INTEG"; 32 33 private const string DEFUNSTART = "DEFUN"; 33 34 private const string ARGSTART = "ARG"; 34 35 private const string INVOKESTART = "CALL"; 36 private const string TIMELAGSTART = "LAG"; 35 37 private Dictionary<string, Symbol> knownSymbols = new Dictionary<string, Symbol>() 36 38 { … … 53 55 {"OR", new Or()}, 54 56 {"NOT", new Not()}, 57 {"DIFF", new Derivative()}, 55 58 {"PROG", new ProgramRootSymbol()}, 56 59 {"MAIN", new StartSymbol()}, … … 61 64 LaggedVariable laggedVariable = new LaggedVariable(); 62 65 Defun defun = new Defun(); 66 TimeLag timeLag = new TimeLag(); 67 Integral integral = new Integral(); 63 68 64 69 ProgramRootSymbol programRootSymbol = new ProgramRootSymbol(); … … 100 105 } else if (tokens.Peek().StringValue.StartsWith(LAGGEDVARSTART)) { 101 106 tree = ParseLaggedVariable(tokens); 107 } else if (tokens.Peek().StringValue.StartsWith(TIMELAGSTART)) { 108 tree = ParseTimeLag(tokens); 109 tree.AddSubtree(ParseSexp(tokens)); 110 } else if (tokens.Peek().StringValue.StartsWith(INTEGRALSTART)) { 111 tree = ParseIntegral(tokens); 112 tree.AddSubtree(ParseSexp(tokens)); 102 113 } else if (tokens.Peek().StringValue.StartsWith(DEFUNSTART)) { 103 114 tree = ParseDefun(tokens); … … 152 163 } 153 164 165 private ISymbolicExpressionTreeNode ParseTimeLag(Queue<Token> tokens) { 166 Token varTok = tokens.Dequeue(); 167 Debug.Assert(varTok.StringValue == "LAG"); 168 LaggedTreeNode t = (LaggedTreeNode)timeLag.CreateTreeNode(); 169 t.Lag = (int)tokens.Dequeue().DoubleValue; 170 return t; 171 } 172 173 private ISymbolicExpressionTreeNode ParseIntegral(Queue<Token> tokens) { 174 Token varTok = tokens.Dequeue(); 175 Debug.Assert(varTok.StringValue == "INTEGRAL"); 176 LaggedTreeNode t = (LaggedTreeNode)integral.CreateTreeNode(); 177 t.Lag = (int)tokens.Dequeue().DoubleValue; 178 return t; 179 } 180 154 181 private ISymbolicExpressionTreeNode ParseVariable(Queue<Token> tokens) { 155 182 Token varTok = tokens.Dequeue();
Note: See TracChangeset
for help on using the changeset viewer.