Free cookie consent management tool by TermsFeed Policy Generator

Changeset 18164 for branches


Ignore:
Timestamp:
12/21/21 15:29:18 (3 years ago)
Author:
dpiringe
Message:

#3136

  • fixed a bug in StructureTemplateView -> only nodes of type SubFunctionTreeNode are selectable
  • added a way to keep old sub functions after parsing a new expression
    • overwrote some basic object methods for SubFunction to keep it simple
    • only old sub functions, which match the name and signature of the new ones, are saved; examples:
      • old: f(x), new: f(x) -> keep old
      • old: f(x1), new: f(x1, x2) -> use new
      • old: f1(x), new f2(x) -> use new
Location:
branches/3136_Structural_GP
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/StructureTemplate/StructureTemplateView.cs

    r18154 r18164  
    4242    private void SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
    4343      var visualTreeNode = sender as VisualTreeNode<ISymbolicExpressionTreeNode>;
    44       if(visualTreeNode != null) {
    45         var subFunctionTreeNode = visualTreeNode.Content as SubFunctionTreeNode;
     44      if(visualTreeNode != null && visualTreeNode.Content is SubFunctionTreeNode subFunctionTreeNode) {
    4645        var selectedSubFunction = Content.SubFunctions.Where(x => x.Name == subFunctionTreeNode.Name).FirstOrDefault();
    4746        if(subFunctionTreeNode != null && selectedSubFunction != null)
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/StructureTemplate.cs

    r18152 r18164  
    3333        treeWithLinearScaling = AddLinearScalingTerms(value);
    3434        treeWithoutLinearScaling = value;
    35         subFunctions = GetSubFunctions();
     35
     36        var newFunctions = GetSubFunctions();
     37        var oldFunctions = subFunctions?.Intersect(newFunctions)
     38                           ?? Enumerable.Empty<SubFunction>();
     39        // adds new functions and keeps the old ones (if they match)
     40        subFunctions = newFunctions.Except(oldFunctions).Concat(oldFunctions).ToList();
    3641      }
    3742    }
  • branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/StructureTemplate/SubFunction.cs

    r18072 r18164  
    7575      new SubFunction(this, cloner);
    7676    #endregion
     77
     78    public override string ToString() => $"{Name}({string.Join(",", Arguments)})";
     79
     80    public override int GetHashCode() => ToString().GetHashCode();
     81
     82    public override bool Equals(object obj) => (obj is SubFunction other) && other.ToString() == ToString();
    7783  }
    7884}
Note: See TracChangeset for help on using the changeset viewer.