Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/24/18 18:48:10 (6 years ago)
Author:
bburlacu
Message:

#2950: Implement first version of hash-based building blocks analyzer. Minor performance improvement in HashExtensions.cs. Fix bug in SymbolicExpressionTreeHash.cs with simplification for Multiplication nodes inadvertently altering constant values.

Location:
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/HashExtensions.cs

    r16252 r16255  
    120120
    121121    public static HashNode<T>[] Sort<T>(this HashNode<T>[] nodes) where T : class {
     122      int sort(int a, int b) => nodes[a].CompareTo(nodes[b]);
     123
    122124      for (int i = 0; i < nodes.Length; ++i) {
    123125        var node = nodes[i];
     
    136138            var sorted = new HashNode<T>[size];
    137139            var indices = nodes.IterateChildren(i);
    138             Array.Sort(indices, (a, b) => nodes[a].CompareTo(nodes[b]));
     140            Array.Sort(indices, sort);
    139141
    140142            int idx = 0;
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/SymbolicExpressionTreeHash.cs

    r16252 r16255  
    1 using System.Collections.Generic;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System.Collections.Generic;
    223using System.Linq;
    324using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     
    103124            var variableTreeNode = (VariableTreeNode)treeNodes[i];
    104125            variableTreeNode.VariableName = variable.VariableName;
    105             variableTreeNode.Weight = 1;
     126            variableTreeNode.Weight = variable.Weight;
    106127          } else if (node.Data is ConstantTreeNode @const) {
    107128            var constantTreeNode = (ConstantTreeNode)treeNodes[i];
     
    175196            var d = children[k];
    176197            if (nodes[d].Data.Symbol is Constant) {
    177               ((ConstantTreeNode)child.Data).Value *= ((ConstantTreeNode)nodes[d].Data).Value;
    178198              nodes[d].Enabled = false;
    179199              node.Arity--;
Note: See TracChangeset for help on using the changeset viewer.