Changeset 16306 for branches/2915-AbsoluteSymbol
- Timestamp:
- 11/19/18 15:37:48 (6 years ago)
- Location:
- branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 16305
- Property svn:mergeinfo changed
-
branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/HashExtensions.cs
r16304 r16306 35 35 public ulong CalculatedHashValue; // the calculated hash value (taking into account the children hash values) 36 36 37 public Action<HashNode<T>[], int> Simplify; 37 public delegate void SimplifyAction(ref HashNode<T>[] nodes, int i); 38 public SimplifyAction Simplify; 39 38 40 public IComparer<T> Comparer; 39 41 … … 108 110 continue; 109 111 } 110 node.Simplify?.Invoke(re duced, i);112 node.Simplify?.Invoke(ref reduced, i); 111 113 } 112 114 // detect if anything was simplified -
branches/2915-AbsoluteSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/SymbolicExpressionTreeHash.cs
r16304 r16306 227 227 } 228 228 229 public static void SimplifyAddition( HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) {229 public static void SimplifyAddition(ref HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) { 230 230 // simplify additions of terms by eliminating terms with the same symbol and hash 231 231 var children = nodes.IterateChildren(i); 232 232 233 // we always assume the child nodes are sorted 233 234 var curr = children[0]; 234 235 var node = nodes[i]; … … 236 237 foreach (var j in children.Skip(1)) { 237 238 if (nodes[j] == nodes[curr]) { 238 for (int k = j - nodes[j].Size; k <= j; ++k) { 239 nodes[k].Enabled = false; 240 } 239 nodes.SetEnabled(j, false); 241 240 node.Arity--; 242 241 } else { … … 250 249 251 250 // simplify multiplications by reducing constants and div terms 252 public static void SimplifyMultiplication( HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) {251 public static void SimplifyMultiplication(ref HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) { 253 252 var node = nodes[i]; 254 253 var children = nodes.IterateChildren(i); … … 298 297 } 299 298 300 public static void SimplifyDivision( HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) {299 public static void SimplifyDivision(ref HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) { 301 300 var node = nodes[i]; 302 301 var children = nodes.IterateChildren(i); 303 302 304 if (children.All(x => nodes[x].Data.Symbol is Constant)) { 303 var tmp = nodes; 304 305 if (children.All(x => tmp[x].Data.Symbol is Constant)) { 305 306 var v = ((ConstantTreeNode)nodes[children.First()].Data).Value; 306 307 if (node.Arity == 1) { … … 333 334 } 334 335 335 public static void SimplifyUnaryNode( HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) {336 public static void SimplifyUnaryNode(ref HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) { 336 337 // check if the child of the unary node is a constant, then the whole node can be simplified 337 338 var parent = nodes[i]; … … 348 349 } 349 350 350 public static void SimplifyBinaryNode( HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) {351 public static void SimplifyBinaryNode(ref HashNode<ISymbolicExpressionTreeNode>[] nodes, int i) { 351 352 var children = nodes.IterateChildren(i); 352 if (children.All(x => nodes[x].Data.Symbol is Constant)) { 353 var tmp = nodes; 354 if (children.All(x => tmp[x].Data.Symbol is Constant)) { 353 355 foreach (var j in children) { 354 356 nodes[j].Enabled = false;
Note: See TracChangeset
for help on using the changeset viewer.