Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16980


Ignore:
Timestamp:
05/23/19 10:23:03 (6 years ago)
Author:
bburlacu
Message:

#2950: Remove building block analyzer (does not belong here), minor refactor in DiversityCrossover.

Location:
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers

    • Property svn:ignore set to
      SymbolicDataAnalysisBuildingBlockAnalyzer.cs
      SymbolicDataAnalysisHashBasedDiversityAnalyzer.cs
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Crossovers/SymbolicDataAnalysisExpressionDiversityPreservingCrossover.cs

    r16565 r16980  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2019 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;
    223using System.Collections.Generic;
    324using System.Linq;
    4 
     25using HEAL.Attic;
    526using HeuristicLab.Common;
    627using HeuristicLab.Core;
     
    829using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    930using HeuristicLab.Parameters;
    10 using HEAL.Attic;
    1131using HeuristicLab.Random;
    1232using static HeuristicLab.Problems.DataAnalysis.Symbolic.SymbolicExpressionHashExtensions;
    1333
    1434namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    15   [Item("DiversityCrossover", "Simple crossover operator prioritizing internal nodes according to the given probability.")]
     35  [Item("DiversityCrossover", "Simple crossover operator preventing swap between subtrees with the same hash value.")]
    1636  [StorableType("ED35B0D9-9704-4D32-B10B-8F9870E76781")]
    1737  public sealed class SymbolicDataAnalysisExpressionDiversityPreservingCrossover<T> : SymbolicDataAnalysisExpressionCrossover<T> where T : class, IDataAnalysisProblemData {
     
    2040    private const string WindowingParameterName = "Windowing";
    2141    private const string ProportionalSamplingParameterName = "ProportionalSampling";
     42    private const string StrictHashingParameterName = "StrictHashing";
    2243
    2344    private static readonly Func<byte[], ulong> hashFunction = HashUtil.JSHash;
     
    3556      get { return (IValueLookupParameter<BoolValue>)Parameters[ProportionalSamplingParameterName]; }
    3657    }
     58
     59    public IFixedValueParameter<BoolValue> StrictHashingParameter {
     60      get { return (IFixedValueParameter<BoolValue>)Parameters[StrictHashingParameterName]; }
     61    }
    3762    #endregion
    3863
     
    4974      get { return ProportionalSamplingParameter.ActualValue; }
    5075    }
     76
     77    bool StrictHashing {
     78      get { return StrictHashingParameter.Value.Value; }
     79    }
    5180    #endregion
     81
     82
     83    [StorableHook(HookType.AfterDeserialization)]
     84    private void AfterDeserialization() {
     85      if (!Parameters.ContainsKey(StrictHashingParameterName)) {
     86        Parameters.Add(new FixedValueParameter<BoolValue>(StrictHashingParameterName, "Use strict hashing when calculating subtree hash values."));
     87      }
     88    }
    5289
    5390    public SymbolicDataAnalysisExpressionDiversityPreservingCrossover() {
     
    5693      Parameters.Add(new ValueLookupParameter<BoolValue>(WindowingParameterName, "Use proportional sampling with windowing for cutpoint selection.", new BoolValue(false)));
    5794      Parameters.Add(new ValueLookupParameter<BoolValue>(ProportionalSamplingParameterName, "Select cutpoints proportionally using probabilities as weights instead of randomly.", new BoolValue(true)));
     95      Parameters.Add(new FixedValueParameter<BoolValue>(StrictHashingParameterName, "Use strict hashing when calculating subtree hash values."));
    5896    }
    5997
     
    72110    }
    73111
    74     public static ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1, double internalCrossoverPointProbability, int maxLength, int maxDepth, bool windowing, bool proportionalSampling = false) {
    75       var leafCrossoverPointProbability = 1 - internalCrossoverPointProbability;
    76 
    77       var nodes0 = ActualRoot(parent0).MakeNodes().Sort(hashFunction);
    78       var nodes1 = ActualRoot(parent1).MakeNodes().Sort(hashFunction);
     112    public static ISymbolicExpressionTree Cross(IRandom random, ISymbolicExpressionTree parent0, ISymbolicExpressionTree parent1, double internalCrossoverPointProbability, int maxLength, int maxDepth, bool windowing, bool proportionalSampling = false, bool strictHashing = false) {
     113      var nodes0 = ActualRoot(parent0).MakeNodes(strictHashing).Sort(hashFunction);
     114      var nodes1 = ActualRoot(parent1).MakeNodes(strictHashing).Sort(hashFunction);
    79115
    80116      IList<HashNode<ISymbolicExpressionTreeNode>> sampled0;
     
    126162      var proportionalSampling = ProportionalSampling.Value;
    127163
    128       return Cross(random, parent0, parent1, internalCrossoverPointProbability, maxLength, maxDepth, windowing, proportionalSampling);
     164      return Cross(random, parent0, parent1, internalCrossoverPointProbability, maxLength, maxDepth, windowing, proportionalSampling, StrictHashing);
    129165    }
    130166
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r16978 r16980  
    132132  <ItemGroup>
    133133    <Compile Include="Analyzers\SymbolicDataAnalysisBottomUpDiversityAnalyzer.cs" />
    134     <Compile Include="Analyzers\SymbolicDataAnalysisBuildingBlockAnalyzer.cs" />
    135134    <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs" />
    136135    <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer.cs" />
Note: See TracChangeset for help on using the changeset viewer.