Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9171


Ignore:
Timestamp:
01/16/13 15:27:40 (11 years ago)
Author:
gkronber
Message:

added comments suggesting a solution for calculating the EMA using a cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sluengo/HeuristicLab.Problems.TradeRules/Interpreter.cs

    r9147 r9171  
    3030        [ThreadStatic]
    3131        private static double lastRSI;
     32   
     33    // [ThreadStatic]
     34    // private Dictionary<Instruction, double> lastEMACache;
     35   
    3236        #region private classes
    3337        //This class manipulate the instructions of the stack
     
    377381            double timeValue = (int)Evaluate(dataset, ref row, state);
    378382
     383            // with caching
     384            // if (lastEmaCache.ContainsKey(currentInst)
     385            //   lastEma = lastEmaCache[currentInstr]
     386            // else
     387            //   lastEma = 1;
     388           
    379389            //get all mean values from row - timeValue up to the actual row
    380390            double[] meanValues = dataset.GetDoubleValues("insert variable name", Enumerable.Range(row - (int)timeValue, timeValue)).ToArray();
     
    386396              EMA = meanValues[i] * factor + (1 - factor) * EMA;
    387397            }
     398           
     399            // save in cache for next evaluation
     400            // lastEmaCache[currentInstr] = EMA;
     401           
    388402            return EMA;
    389403                    }
     
    563577                }
    564578            }
     579     
     580      // with caching
     581      // if (lastEmaCache == null) lastEmaCache = new Dictionary<Instruction, double>();
     582      // else lastEmaCache.Clear();
     583     
    565584            var state = new InterpreterState(code, necessaryArgStackSize);
    566585            //Evaluate each row of the datase
Note: See TracChangeset for help on using the changeset viewer.