Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/27/08 15:13:59 (16 years ago)
Author:
gkronber
Message:

quick fix for #327.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification/BakedTreeEvaluator.cs

    r656 r699  
    3131namespace HeuristicLab.GP.StructureIdentification {
    3232  public class BakedTreeEvaluator {
    33     private const int MAX_TREE_SIZE = 4096;
    3433    private const double EPSILON = 1.0e-7;
    3534
     
    4342    }
    4443
    45     private Instr[] codeArr;
     44    private List<Instr> code;
    4645    private int PC;
    4746    private Dataset dataset;
     
    5049
    5150    public BakedTreeEvaluator() {
    52       codeArr = new Instr[MAX_TREE_SIZE];
    53       for(int i = 0; i < MAX_TREE_SIZE; i++) {
    54         codeArr[i] = new Instr();
    55       }
     51      code = new List<Instr>();
    5652    }
    5753
     
    5955      this.dataset = dataset;
    6056      List<LightWeightFunction> linearRepresentation = functionTree.LinearRepresentation;
    61       int i = 0;
     57      code.Clear();
    6258      foreach(LightWeightFunction f in linearRepresentation) {
    63         TranslateToInstr(f, codeArr[i++]);
    64       }
    65     }
    66 
    67     private Instr TranslateToInstr(LightWeightFunction f, Instr instr) {
     59        Instr curInstr = new Instr();
     60        TranslateToInstr(f, curInstr);
     61        code.Add(curInstr);
     62      }
     63    }
     64
     65    private void TranslateToInstr(LightWeightFunction f, Instr instr) {
    6866      instr.arity = f.arity;
    6967      instr.symbol = EvaluatorSymbolTable.MapFunction(f.functionType);
     
    8583          }
    8684      }
    87       return instr;
    8885    }
    8986
     
    9895      int i = 1;
    9996      while(i > 0) {
    100         i += codeArr[PC++].arity;
     97        i += code[PC++].arity;
    10198        i--;
    10299      }
     
    104101
    105102    private double EvaluateBakedCode() {
    106       Instr currInstr = codeArr[PC++];
     103      Instr currInstr = code[PC++];
    107104      switch(currInstr.symbol) {
    108105        case EvaluatorSymbolTable.VARIABLE: {
Note: See TracChangeset for help on using the changeset viewer.