Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/15/21 11:50:57 (3 years ago)
Author:
gkronber
Message:

#3140: merged r18091:18131 from branch to trunk

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic

  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeBottomUpSimilarityCalculator.cs

    r17180 r18132  
    4141    protected override bool IsCommutative { get { return true; } }
    4242
    43     public bool MatchConstantValues { get; set; }
     43    public bool MatchParameterValues { get; set; }
    4444    public bool MatchVariableWeights { get; set; }
    4545
     
    6666
    6767    public static double CalculateSimilarity(ISymbolicExpressionTreeNode n1, ISymbolicExpressionTreeNode n2, bool strict = false) {
    68       var calculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator { MatchConstantValues = strict, MatchVariableWeights = strict };
    6968      return CalculateSimilarity(n1, n2, strict);
    7069    }
    7170
    72     public static Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> ComputeBottomUpMapping(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2, bool strict = false) {
     71    public static NodeMap ComputeBottomUpMapping(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2, bool strict = false) {
    7372      return ComputeBottomUpMapping(ActualRoot(t1), ActualRoot(t2), strict);
    7473    }
    7574
    76     public static Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> ComputeBottomUpMapping(ISymbolicExpressionTreeNode n1, ISymbolicExpressionTreeNode n2, bool strict = false) {
    77       var calculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator { MatchConstantValues = strict, MatchVariableWeights = strict };
     75    public static NodeMap ComputeBottomUpMapping(ISymbolicExpressionTreeNode n1, ISymbolicExpressionTreeNode n2, bool strict = false) {
     76      var calculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator { MatchParameterValues = strict, MatchVariableWeights = strict };
    7877      return calculator.ComputeBottomUpMapping(n1, n2);
    7978    }
     
    8180
    8281    public double CalculateSimilarity(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) {
    83       return CalculateSimilarity(t1, t2, out Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> map);
     82      return CalculateSimilarity(t1, t2, out _);
    8483    }
    8584
     
    110109    }
    111110
    112     public Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> ComputeBottomUpMapping(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) {
     111    public NodeMap ComputeBottomUpMapping(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) {
    113112      return ComputeBottomUpMapping(ActualRoot(t1), ActualRoot(t2));
    114113    }
    115114
    116     public Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> ComputeBottomUpMapping(ISymbolicExpressionTreeNode n1, ISymbolicExpressionTreeNode n2) {
     115    public NodeMap ComputeBottomUpMapping(ISymbolicExpressionTreeNode n1, ISymbolicExpressionTreeNode n2) {
    117116      var compactedGraph = Compact(n1, n2);
    118117
     
    211210        return node.Symbol.Name;
    212211
    213       if (node is ConstantTreeNode constant)
    214         return MatchConstantValues ? constant.Value.ToString(CultureInfo.InvariantCulture) : constant.Symbol.Name;
     212      if (node is INumericTreeNode numNode)
     213        return MatchParameterValues ? numNode.Value.ToString(CultureInfo.InvariantCulture) : "Numeric";
    215214
    216215      if (node is VariableTreeNode variable)
Note: See TracChangeset for help on using the changeset viewer.