Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/14/08 20:14:07 (17 years ago)
Author:
gkronber
Message:

fixed #146 (serialization of function-trees in linear form)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Functions/BakedFunctionTree.cs

    r259 r260  
    3434    private List<int> code;
    3535    private List<double> data;
    36     private static BakedTreeEvaluator evaluator = new BakedTreeEvaluator();
     36    private static EvaluatorSymbolTable symbolTable = EvaluatorSymbolTable.SymbolTable;
    3737    public BakedFunctionTree() {
    3838      code = new List<int>();
     
    4343      : this() {
    4444      code.Add(0);
    45       code.Add(evaluator.MapFunction(function));
     45      code.Add(symbolTable.MapFunction(function));
    4646      code.Add(0);
    4747      treesExpanded = true;
     
    5959      : this() {
    6060      code.Add(0);
    61       code.Add(evaluator.MapFunction(tree.Function));
     61      code.Add(symbolTable.MapFunction(tree.Function));
    6262      code.Add(tree.LocalVariables.Count);
    6363      foreach(IVariable variable in tree.LocalVariables) {
     
    159159        if(!variablesExpanded) {
    160160          variables = new List<IVariable>();
    161           IFunction function = evaluator.MapSymbol(code[1]);
     161          IFunction function = symbolTable.MapSymbol(code[1]);
    162162          int localVariableIndex = 0;
    163163          foreach(IVariableInfo variableInfo in function.VariableInfos) {
     
    187187
    188188    public IFunction Function {
    189       get { return evaluator.MapSymbol(code[1]); }
     189      get { return symbolTable.MapSymbol(code[1]); }
    190190    }
    191191
     
    221221    }
    222222
     223    private BakedTreeEvaluator evaluator = null;
    223224    public double Evaluate(Dataset dataset, int sampleIndex) {
    224225      FlattenVariables();
    225226      FlattenTrees();
    226       evaluator.SetCode(code, data);
     227      if(evaluator == null) evaluator = new BakedTreeEvaluator(code, data);
    227228      return evaluator.Evaluate(dataset, sampleIndex);
    228229    }
     
    250251      XmlNode evaluatorNode = node.SelectSingleNode("Evaluator");
    251252      if(evaluatorNode != null) {
    252         BakedTreeEvaluator evaluator = (BakedTreeEvaluator)PersistenceManager.Restore(evaluatorNode, restoredObjects);
    253         BakedFunctionTree.evaluator = evaluator;
     253        this.evaluator = (BakedTreeEvaluator)PersistenceManager.Restore(evaluatorNode, restoredObjects);
    254254      }
    255255      code = GetList<int>(node.Attributes["Code"].Value, s => int.Parse(s, CultureInfo.InvariantCulture));
    256256      data = GetList<double>(node.Attributes["Data"].Value, s => double.Parse(s, CultureInfo.InvariantCulture));
     257      treesExpanded = false;
     258      variablesExpanded = false;
    257259    }
    258260
Note: See TracChangeset for help on using the changeset viewer.