Changeset 17076 for trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/SymbolicExpressionTreeHash.cs
 Timestamp:
 07/05/19 10:26:41 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/SymbolicExpressionTreeHash.cs
r16983 r17076 48 48 ulong hashFunction(byte[] input) => HashUtil.DJBHash(input); 49 49 50 var hashNodes = simplify ? node.MakeNodes(strict).Simplify(hashFunction) : node.MakeNodes(strict).Sort(hashFunction); 50 var hashNodes = simplify ? node.MakeNodes(strict).Simplify(hashFunction) : node.MakeNodes(strict).Sort(hashFunction); // simplify sorts implicitly 51 51 var hashes = new ulong[hashNodes.Length]; 52 52 for (int i = 0; i < hashes.Length; ++i) { … … 210 210 var treeNodes = nodes.Select(x => x.Data.Symbol.CreateTreeNode()).ToArray(); 211 211 212 // construct tree top down (assumes postfix order for nodes) 212 213 for (int i = nodes.Length  1; i >= 0; i) { 213 214 var node = nodes[i]; … … 244 245 // (in other words simplification should be applied in a bottomup fashion) 245 246 public static ISymbolicExpressionTree Simplify(ISymbolicExpressionTree tree) { 246 ulong hashFunction(byte[] bytes) => HashUtil. JSHash(bytes);247 var root = tree. Root.GetSubtree(0).GetSubtree(0);247 ulong hashFunction(byte[] bytes) => HashUtil.DJBHash(bytes); 248 var root = tree.ActualRoot(); 248 249 var nodes = root.MakeNodes(); 249 250 var simplified = nodes.Simplify(hashFunction); … … 369 370 nodes[i].Enabled = false; 370 371 } else if ((parentSymbol is Exponential && childSymbol is Logarithm)  (parentSymbol is Logarithm && childSymbol is Exponential)) { 372 // exp(log(x)) == x only for positive x. We consider this as equivalent for hashing anyway. 371 373 child.Enabled = parent.Enabled = false; 372 374 }
Note: See TracChangeset
for help on using the changeset viewer.