Changeset 260 for trunk/sources/HeuristicLab.Functions/BakedFunctionTree.cs
- Timestamp:
- 05/14/08 20:14:07 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/BakedFunctionTree.cs
r259 r260 34 34 private List<int> code; 35 35 private List<double> data; 36 private static BakedTreeEvaluator evaluator = new BakedTreeEvaluator();36 private static EvaluatorSymbolTable symbolTable = EvaluatorSymbolTable.SymbolTable; 37 37 public BakedFunctionTree() { 38 38 code = new List<int>(); … … 43 43 : this() { 44 44 code.Add(0); 45 code.Add( evaluator.MapFunction(function));45 code.Add(symbolTable.MapFunction(function)); 46 46 code.Add(0); 47 47 treesExpanded = true; … … 59 59 : this() { 60 60 code.Add(0); 61 code.Add( evaluator.MapFunction(tree.Function));61 code.Add(symbolTable.MapFunction(tree.Function)); 62 62 code.Add(tree.LocalVariables.Count); 63 63 foreach(IVariable variable in tree.LocalVariables) { … … 159 159 if(!variablesExpanded) { 160 160 variables = new List<IVariable>(); 161 IFunction function = evaluator.MapSymbol(code[1]);161 IFunction function = symbolTable.MapSymbol(code[1]); 162 162 int localVariableIndex = 0; 163 163 foreach(IVariableInfo variableInfo in function.VariableInfos) { … … 187 187 188 188 public IFunction Function { 189 get { return evaluator.MapSymbol(code[1]); }189 get { return symbolTable.MapSymbol(code[1]); } 190 190 } 191 191 … … 221 221 } 222 222 223 private BakedTreeEvaluator evaluator = null; 223 224 public double Evaluate(Dataset dataset, int sampleIndex) { 224 225 FlattenVariables(); 225 226 FlattenTrees(); 226 evaluator.SetCode(code, data);227 if(evaluator == null) evaluator = new BakedTreeEvaluator(code, data); 227 228 return evaluator.Evaluate(dataset, sampleIndex); 228 229 } … … 250 251 XmlNode evaluatorNode = node.SelectSingleNode("Evaluator"); 251 252 if(evaluatorNode != null) { 252 BakedTreeEvaluator evaluator = (BakedTreeEvaluator)PersistenceManager.Restore(evaluatorNode, restoredObjects); 253 BakedFunctionTree.evaluator = evaluator; 253 this.evaluator = (BakedTreeEvaluator)PersistenceManager.Restore(evaluatorNode, restoredObjects); 254 254 } 255 255 code = GetList<int>(node.Attributes["Code"].Value, s => int.Parse(s, CultureInfo.InvariantCulture)); 256 256 data = GetList<double>(node.Attributes["Data"].Value, s => double.Parse(s, CultureInfo.InvariantCulture)); 257 treesExpanded = false; 258 variablesExpanded = false; 257 259 } 258 260
Note: See TracChangeset
for help on using the changeset viewer.