- Timestamp:
- 05/13/08 15:10:57 (17 years ago)
- Location:
- trunk/sources/HeuristicLab.Functions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/BakedFunctionTree.cs
r229 r239 220 220 } 221 221 222 private BakedTreeEvaluator evaluator; 222 223 public double Evaluate(Dataset dataset, int sampleIndex) { 223 224 FlattenVariables(); 224 225 FlattenTrees(); 225 return BakedTreeEvaluator.Evaluate(dataset, sampleIndex, code, data); 226 if(evaluator == null) evaluator = new BakedTreeEvaluator(code, data); 227 return evaluator.Evaluate(dataset, sampleIndex); 226 228 } 227 229 -
trunk/sources/HeuristicLab.Functions/BakedTreeEvaluator.cs
r236 r239 6 6 7 7 namespace HeuristicLab.Functions { 8 staticclass BakedTreeEvaluator {8 internal class BakedTreeEvaluator { 9 9 private const int ADDITION = 10010; 10 10 private const int AND = 10020; … … 35 35 private static Dictionary<IFunction, int> reverseSymbolTable; 36 36 private static Dictionary<Type, int> staticTypes; 37 private static int MAX_CODE_LENGTH = 4096; 38 private static int MAX_DATA_LENGTH = 4096; 39 private static int[] codeArr = new int[MAX_CODE_LENGTH]; 40 private static double[] dataArr = new double[MAX_DATA_LENGTH]; 37 41 38 42 static BakedTreeEvaluator() { … … 65 69 } 66 70 71 internal BakedTreeEvaluator(List<int> code, List<double> data) { 72 code.CopyTo(codeArr); 73 data.CopyTo(dataArr); 74 } 75 67 76 internal static int MapFunction(IFunction function) { 68 77 if(!reverseSymbolTable.ContainsKey(function)) { … … 84 93 85 94 86 private static int PC; 87 private static int DP; 88 private static int MAX_CODE_LENGTH = 4096; 89 private static int MAX_DATA_LENGTH = 4096; 90 private static int[] codeArr = new int[MAX_CODE_LENGTH]; 91 private static double[] dataArr = new double[MAX_DATA_LENGTH]; 92 private static Dataset dataset; 93 private static int sampleIndex; 94 95 internal static double Evaluate(Dataset _dataset, int _sampleIndex, List<int> code, List<double> data) { 95 private int PC; 96 private int DP; 97 private Dataset dataset; 98 private int sampleIndex; 99 100 internal double Evaluate(Dataset _dataset, int _sampleIndex) { 96 101 PC = 0; 97 102 DP = 0; 98 code.CopyTo(codeArr);99 data.CopyTo(dataArr);100 103 sampleIndex = _sampleIndex; 101 104 dataset = _dataset; … … 103 106 } 104 107 105 private staticdouble EvaluateBakedCode() {108 private double EvaluateBakedCode() { 106 109 int arity = codeArr[PC]; 107 110 int functionSymbol = codeArr[PC+1];
Note: See TracChangeset
for help on using the changeset viewer.