Free cookie consent management tool by TermsFeed Policy Generator

Changeset 430


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
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Constraints/AllSubOperatorsTypeConstraintView.cs

    r2 r430  
    8787    #endregion
    8888
    89     #region Drag Events   
    90 
     89    #region Drag Events
    9190    private void listView_DragDrop(object sender, DragEventArgs e) {
    9291      if(e.Effect != DragDropEffects.None) {
     
    105104    }
    106105
    107 
    108106    private void listView_DragEnter(object sender, DragEventArgs e) {
    109107      this.FindForm().BringToFront();
     
    117115      }
    118116    }
    119 
    120117
    121118    private void listView_DragOver(object sender, DragEventArgs e) {
  • trunk/sources/HeuristicLab.Constraints/SubOperatorsConstraintAnalyser.cs

    r155 r430  
    9191    private static bool InSet(IOperator op, ICollection<IOperator> set) {
    9292      foreach(IOperator element in set) {
    93         if(element==op ||
    94           ((StringData)element.GetVariable("TypeId").Value).Data ==
    95           ((StringData)op.GetVariable("TypeId").Value).Data) {
     93        if(element == op)
    9694          return true;
    97         }
    9895      }
    99 
    10096      return false;
    10197    }
     
    132128        }
    133129      }
    134      
     130
    135131      public override void Visit(OrConstraint constraint) {
    136132        base.Visit(constraint);
  • trunk/sources/HeuristicLab.Constraints/SubOperatorsTypeConstraint.cs

    r2 r430  
    5555      // check if already in the list of allowed functions
    5656      foreach(IOperator existingOp in subOperators) {
    57         if (IsOperatorTypeEqual(existingOp, op)) {
     57        if(existingOp == op) {
    5858          return;
    5959        }
     
    6666      IOperator matchingOperator = null;
    6767      foreach(IOperator existingOp in subOperators) {
    68         if(IsOperatorTypeEqual(existingOp, op)) {
     68        if(existingOp == op) {
    6969          matchingOperator = existingOp;
    7070          break;
     
    7272      }
    7373
    74       if (matchingOperator != null) {
     74      if(matchingOperator != null) {
    7575        subOperators.Remove(matchingOperator);
    7676      }
     
    7979    public override bool Check(IItem data) {
    8080      IOperator op = data as IOperator;
    81       if (data == null) return false;
     81      if(data == null) return false;
    8282
    8383      if(op.SubOperators.Count <= subOperatorIndex.Data) {
    8484        return false;
    8585      }
    86      
    87       return subOperators.Exists(delegate(IOperator curOp) { return IsOperatorTypeEqual(curOp, op.SubOperators[subOperatorIndex.Data]); });
     86
     87      return subOperators.Exists(delegate(IOperator curOp) { return curOp == op.SubOperators[subOperatorIndex.Data]; });
    8888    }
    8989
     
    108108
    109109    #region persistence
    110     public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid,IStorable> persistedObjects) {
     110    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
    111111      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
    112112      XmlNode indexNode = PersistenceManager.Persist("SubOperatorIndex", subOperatorIndex, document, persistedObjects);
     
    121121    }
    122122
    123     public override void Populate(XmlNode node, IDictionary<Guid,IStorable> restoredObjects) {
     123    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
    124124      base.Populate(node, restoredObjects);
    125125      subOperatorIndex = (IntData)PersistenceManager.Restore(node.SelectSingleNode("SubOperatorIndex"), restoredObjects);
     
    131131    #endregion persistence
    132132
    133 
    134     private bool IsOperatorTypeEqual(IOperator f, IOperator g) {
    135       return ((StringData)f.GetVariable("TypeId").Value).Data == ((StringData)g.GetVariable("TypeId").Value).Data;
    136     }
    137133  }
    138134}
  • 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.