Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/08 23:14:08 (16 years ago)
Author:
gkronber
Message:

removed 'TypeIds' for functions (also a relic of an old design) (ticket #225)

Location:
trunk/sources/HeuristicLab.StructureIdentification
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.StructureIdentification/GPOperatorGroup.cs

    r429 r430  
    4141      var localVariableInfos = op.VariableInfos.Where(f => f.Local);
    4242
    43       // add a new typeid if necessary
    44       if(op.GetVariable(GPOperatorLibrary.TYPE_ID) == null) {
    45         op.AddVariable(new Variable(GPOperatorLibrary.TYPE_ID, new StringData(Guid.NewGuid().ToString())));
    46       }
    47 
    4843      if(op.GetVariable(GPOperatorLibrary.MIN_TREE_HEIGHT) == null) {
    4944        op.AddVariable(new Variable(GPOperatorLibrary.MIN_TREE_HEIGHT, new IntData(-1)));
     
    6257
    6358
    64     private Dictionary<string, int> minTreeHeight = new Dictionary<string, int>();
    65     private Dictionary<string, int> minTreeSize = new Dictionary<string, int>();
     59    private Dictionary<IOperator, int> minTreeHeight = new Dictionary<IOperator, int>();
     60    private Dictionary<IOperator, int> minTreeSize = new Dictionary<IOperator, int>();
    6661    private SubOperatorsConstraintAnalyser constraintAnalyser = new SubOperatorsConstraintAnalyser();
    6762
     
    10196
    10297    private int RecalculateMinimalTreeSize(IOperator op) {
    103       string typeId = GetTypeId(op);
    10498      // check for memoized value
    105       if(minTreeSize.ContainsKey(typeId)) {
    106         return minTreeSize[typeId];
     99      if(minTreeSize.ContainsKey(op)) {
     100        return minTreeSize[op];
    107101      }
    108102
     
    112106      // no suboperators possible => minimalTreeSize == 1 (the current node)
    113107      if(minArity == 0 && maxArity == 0) {
    114         minTreeSize[typeId] = 1;
     108        minTreeSize[op] = 1;
    115109        return 1;
    116110      }
     
    121115
    122116      // mark the currently processed operator to prevent infinite recursions and stack overflow
    123       minTreeSize[typeId] = 9999;
     117      minTreeSize[op] = 9999;
    124118      for(int i = 0; i < minArity; i++) {
    125119        // calculate the minTreeSize of all allowed sub-operators
     
    136130      }
    137131
    138       minTreeSize[typeId] = subTreeSizeSum + 1;
     132      minTreeSize[op] = subTreeSizeSum + 1;
    139133      return subTreeSizeSum + 1;
    140134    }
     
    142136
    143137    private int RecalculateMinimalTreeHeight(IOperator op) {
    144       string typeId = GetTypeId(op);
    145138      // check for memoized value
    146       if(minTreeHeight.ContainsKey(typeId)) {
    147         return minTreeHeight[typeId];
     139      if(minTreeHeight.ContainsKey(op)) {
     140        return minTreeHeight[op];
    148141      }
    149142
     
    153146      // no suboperators possible => minimalTreeHeight == 1
    154147      if(minArity == 0 && maxArity == 0) {
    155         minTreeHeight[typeId] = 1;
     148        minTreeHeight[op] = 1;
    156149        return 1;
    157150      }
     
    162155
    163156      // mark the currently processed operator to prevent infinite recursions leading to stack overflow
    164       minTreeHeight[typeId] = 9999;
     157      minTreeHeight[op] = 9999;
    165158      for(int i = 0; i < minArity; i++) {
    166159        // calculate the minTreeHeight of all possible sub-operators.
     
    182175      }
    183176
    184       minTreeHeight[typeId] = maxSubTreeHeight + 1;
     177      minTreeHeight[op] = maxSubTreeHeight + 1;
    185178      return maxSubTreeHeight + 1;
    186179    }
     
    200193    }
    201194
    202     private string GetTypeId(IOperator op) {
    203       return ((StringData)op.GetVariable(GPOperatorLibrary.TYPE_ID).Value).Data;
    204     }
    205 
    206195    public override void AddSubGroup(IOperatorGroup group) {
    207196      throw new NotSupportedException();
     
    210199    public override void RemoveOperator(IOperator op) {
    211200      base.RemoveOperator(op);
    212       op.RemoveVariable(GPOperatorLibrary.TYPE_ID);
    213201      op.RemoveVariable(GPOperatorLibrary.MIN_TREE_SIZE);
    214202      op.RemoveVariable(GPOperatorLibrary.MIN_TREE_HEIGHT);
  • trunk/sources/HeuristicLab.StructureIdentification/GPOperatorLibrary.cs

    r428 r430  
    3030  public class GPOperatorLibrary : ItemBase, IOperatorLibrary, IEditable  {
    3131    // constants for variable names
    32     internal const string TYPE_ID = "TypeId";
    3332    internal const string MIN_TREE_HEIGHT = "MinTreeHeight";
    3433    internal const string MIN_TREE_SIZE = "MinTreeSize";
Note: See TracChangeset for help on using the changeset viewer.