Changeset 12951


Ignore:
Timestamp:
09/15/15 00:10:33 (7 years ago)
Author:
bburlacu
Message:

#1772:

  • Slight refactor in QueryMatch.cs
  • Added a parameter to the genealogy analyzer for removing older generations from the graph (useful to conserve memory in experiments)
  • Updated wildcard nodes (added persistence & cloning)
  • Implemented diversification strategy based on schema frequencies & phenotypic similarity as a separate operator (for now keep also the analyzer)
  • Updated license headers
  • Added QueryMatch performance test (to be expanded)
Location:
branches/HeuristicLab.EvolutionTracking
Files:
7 added
12 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Tests/HeuristicLab.EvolutionTracking.Tests.csproj

    r12208 r12951  
    3939    <Reference Include="HeuristicLab.Common-3.3">
    4040      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
     41      <Private>False</Private>
    4142    </Reference>
    4243    <Reference Include="HeuristicLab.Core-3.3">
    4344      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
    4445    </Reference>
     46    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     47      <SpecificVersion>False</SpecificVersion>
     48      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     49      <Private>False</Private>
     50    </Reference>
     51    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     52      <SpecificVersion>False</SpecificVersion>
     53      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     54      <Private>False</Private>
     55    </Reference>
    4556    <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    4657      <SpecificVersion>False</SpecificVersion>
    4758      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Persistence-3.3.dll</HintPath>
     59      <Private>False</Private>
     60    </Reference>
     61    <Reference Include="HeuristicLab.Random-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     62      <SpecificVersion>False</SpecificVersion>
     63      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Random-3.3.dll</HintPath>
     64      <Private>False</Private>
    4865    </Reference>
    4966    <Reference Include="System" />
     
    5774    <Otherwise>
    5875      <ItemGroup>
    59         <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
     76        <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
     77          <Private>False</Private>
     78        </Reference>
    6079      </ItemGroup>
    6180    </Otherwise>
     
    6483    <Compile Include="GenealogyOperationsPerformanceTests.cs" />
    6584    <Compile Include="Properties\AssemblyInfo.cs" />
     85    <Compile Include="QueryMatchPerformanceTest.cs" />
    6686  </ItemGroup>
    6787  <ItemGroup>
     
    6989      <Project>{06d4a186-9319-48a0-bade-a2058d462eea}</Project>
    7090      <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name>
     91      <Private>False</Private>
    7192    </ProjectReference>
    7293    <ProjectReference Include="..\HeuristicLab.EvolutionTracking\3.4\HeuristicLab.EvolutionTracking-3.4.csproj">
    7394      <Project>{1f75cea3-464f-4a6f-b2f0-04b9841ebc16}</Project>
    7495      <Name>HeuristicLab.EvolutionTracking-3.4</Name>
     96      <Private>False</Private>
    7597    </ProjectReference>
    7698    <ProjectReference Include="..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj">
    7799      <Project>{3d28463f-ec96-4d82-afee-38be91a0ca00}</Project>
    78100      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name>
     101      <Private>False</Private>
    79102    </ProjectReference>
    80103  </ItemGroup>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Analyzers/GenealogyAnalyzer.cs

    r12892 r12951  
    5555    private const string EnableManipulatorTrackingParameterName = "EnableManipulatorTracking";
    5656    private const string EnableSolutionCreatorTrackingParameterName = "EnableSolutionCreatorTracking"; // should always be enabled. maybe superfluous
     57    private const string TrimOlderGenerationsParameterName = "TrimOlderGenerations";
    5758    #endregion parameter names
    5859
    5960    #region parameter properties
     61
     62    public IFixedValueParameter<BoolValue> TrimOlderGenerationsParameter {
     63      get { return (IFixedValueParameter<BoolValue>)Parameters[TrimOlderGenerationsParameterName]; }
     64    }
     65
    6066    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
    6167      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters[QualityParameterName]; }
     
    142148    public BoolValue EnableSolutionCreatorTracking {
    143149      get { return EnableSolutionCreatorTrackingParameter.Value; }
     150    }
     151
     152    public bool TrimOlderGenerations {
     153      get { return TrimOlderGenerationsParameter.Value.Value; }
    144154    }
    145155    #endregion properties
     
    164174      Parameters.Add(new ValueParameter<IManipulatorOperator<T>>(BeforeManipulatorOperatorParameterName));
    165175      Parameters.Add(new ValueParameter<IManipulatorOperator<T>>(AfterManipulatorOperatorParameterName));
     176      Parameters.Add(new FixedValueParameter<BoolValue>(TrimOlderGenerationsParameterName, "Remove all the generations older than the last generation from the genealoy graph to save memory."));
    166177      #endregion add parameters
    167178    }
     
    201212        Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(QualityParameterName, "The individual qualities."));
    202213      }
     214      if (!Parameters.ContainsKey(TrimOlderGenerationsParameterName))
     215        Parameters.Add(new FixedValueParameter<BoolValue>(TrimOlderGenerationsParameterName, "Remove all the generations older than the last generation from the genealoy graph to save memory."));
    203216    }
    204217
     
    318331      genealogyGraph.RemoveVertices(discarded);
    319332
     333      //trim
     334      if (TrimOlderGenerations) {
     335        for (int i = 0; i < generation - 1; ++i) {
     336          var vertices = genealogyGraph.GetByRank(i).ToList();
     337          genealogyGraph.RemoveVertices(vertices);
     338        }
     339      }
     340
    320341      return base.Apply();
    321342    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs

    r11858 r12951  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2929  [StorableClass]
    3030  [Item("AfterCrossoverOperator", "Performs an action after the crossover operator is applied.")]
    31   public class BeforeManipulatorOperator<T> : EvolutionTrackingOperator<T>, IManipulatorOperator<T> where T : class,IItem {
     31  public class BeforeManipulatorOperator<T> : EvolutionTrackingOperator<T>, IManipulatorOperator<T> where T : class, IItem {
    3232    private const string ChildParameterName = "Child";
    3333
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/EvolutionTrackingOperator.cs

    r11227 r12951  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3131  [Item("EvolutionTrackingOperator", "A base operator which facilitates access to the genealogy graph.")]
    3232  [StorableClass]
    33   public class EvolutionTrackingOperator<T> : SingleSuccessorOperator where T : class,IItem {
     33  public class EvolutionTrackingOperator<T> : SingleSuccessorOperator where T : class, IItem {
    3434    // evolution tracking-related parameters
    35     private const string resultsParameterName = "Results";
    36     private const string populationGraphParameterName = "PopulationGraph";
    37     private const string generationsParameterName = "Generations";
     35    private const string ResultsParameterName = "Results";
     36    private const string PopulationGraphParameterName = "PopulationGraph";
     37    private const string GenerationsParameterName = "Generations";
    3838
    3939    public ILookupParameter<ResultCollection> ResultsParameter {
    40       get { return (ILookupParameter<ResultCollection>)Parameters[resultsParameterName]; }
     40      get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
    4141    }
    4242    public ILookupParameter<IntValue> GenerationsParameter {
    43       get { return (ILookupParameter<IntValue>)Parameters[generationsParameterName]; }
     43      get { return (ILookupParameter<IntValue>)Parameters[GenerationsParameterName]; }
    4444    }
    4545    public ResultCollection Results {
     
    5252      get {
    5353        IResult result;
    54         if (!Results.ContainsKey(populationGraphParameterName)) {
    55           result = new Result(populationGraphParameterName, new GenealogyGraph<T>());
     54        if (!Results.ContainsKey(PopulationGraphParameterName)) {
     55          result = new Result(PopulationGraphParameterName, new GenealogyGraph<T>());
    5656          Results.Add(result);
    5757        } else {
    58           result = Results[populationGraphParameterName];
     58          result = Results[PopulationGraphParameterName];
    5959        }
    6060        var graph = (GenealogyGraph<T>)result.Value;
     
    6363    }
    6464    public EvolutionTrackingOperator() {
    65       Parameters.Add(new LookupParameter<IntValue>(generationsParameterName));
    66       Parameters.Add(new LookupParameter<ResultCollection>(resultsParameterName));
     65      Parameters.Add(new LookupParameter<IntValue>(GenerationsParameterName));
     66      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName));
    6767    }
    6868    protected EvolutionTrackingOperator(EvolutionTrackingOperator<T> original, Cloner cloner)
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r12929 r12951  
    313313    <Compile Include="Symbols\VariableConditionTreeNode.cs" />
    314314    <Compile Include="Symbols\VariableTreeNode.cs" />
     315    <Compile Include="Tracking\Analyzers\SymbolicDataAnalysisSchemaFrequencyAnalyzer.cs" />
    315316    <Compile Include="Tracking\Analyzers\SymbolicDataAnalysisFragmentLengthAnalyzer.cs" />
    316317    <Compile Include="Tracking\Analyzers\SymbolicDataAnalysisSubtreeSampleCountAnalyzer.cs" />
    317318    <Compile Include="Tracking\Analyzers\SymbolicDataAnalysisTraceOverlapAnalyzer.cs" />
     319    <Compile Include="Tracking\SchemaDiversification\SchemaCleanupOperator.cs" />
     320    <Compile Include="Tracking\SchemaDiversification\SchemaEvaluator.cs" />
     321    <Compile Include="Tracking\SchemaDiversification\SchemaCreator.cs" />
     322    <Compile Include="Tracking\SchemaDiversification\UpdateEstimatedValuesOperator.cs" />
    318323    <Compile Include="Tracking\SymbolicDataAnalysisExpressionAfterCrossoverOperator.cs" />
    319324    <Compile Include="Tracking\SymbolicDataAnalysisExpressionAfterManipulatorOperator.cs" />
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Wildcards/AnyNode.cs

    r12929 r12951  
    2727  [StorableClass]
    2828  public class AnyNode : SymbolicExpressionTreeNode {
     29    [StorableConstructor]
    2930    protected AnyNode(bool deserializing) : base(deserializing) { }
    3031
    3132    protected AnyNode(AnyNode original, Cloner cloner) : base(original, cloner) { }
    3233
     34    public override IDeepCloneable Clone(Cloner cloner) {
     35      return new AnyNode(this, cloner);
     36    }
     37
    3338    public AnyNode(AnyNodeSymbol symbol) : base(symbol) { }
    3439  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Wildcards/AnyNodeSymbol.cs

    r12929 r12951  
    4545    public AnyNodeSymbol(int minimumArity, int maximumArity)
    4646      : base("=", "A wildcard symbol that can match any node of the same type (function or leaf node)") {
    47       MinimumArity = minimumArity;
    48       MaximumArity = maximumArity;
     47      this.MinimumArity = minimumArity;
     48      this.MaximumArity = maximumArity;
    4949    }
    5050
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/Wildcards/AnySubtree.cs

    r12929 r12951  
    2727  [StorableClass]
    2828  public class AnySubtree : SymbolicExpressionTreeNode {
     29    [StorableConstructor]
    2930    protected AnySubtree(bool deserializing) : base(deserializing) {
    3031    }
     
    3334    }
    3435
     36    public override IDeepCloneable Clone(Cloner cloner) {
     37      return new AnySubtree(this, cloner);
     38    }
     39
    3540    public AnySubtree(AnySubtreeSymbol symbol) : base(symbol) {
    3641    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionAfterManipulatorOperator.cs

    r12287 r12951  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionBeforeCrossoverOperator.cs

    r12287 r12951  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionBeforeManipulatorOperator.cs

    r12287 r12951  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/QueryMatch.cs

    r12942 r12951  
    4242    public QueryMatch(ISymbolicExpressionTreeNodeEqualityComparer comparer) {
    4343      this.comparer = comparer;
     44    }
     45
     46    public bool Match(ISymbolicExpressionTree data, ISymbolicExpressionTree query) {
     47      return Match(data.Root.GetSubtree(0).GetSubtree(0), query.Root.GetSubtree(0).GetSubtree(0));
    4448    }
    4549
     
    100104        if (qTree.Index < qHedge.Index) {
    101105          var rtop = Rtop(qTree.Next, qHedge);
    102           while (rtop.Index < qHedge.Next.Index && qHedge.Index < rtop.LastSibling.Index) {
     106          while (rtop.Index < int.MaxValue && qHedge.Index < rtop.LastSibling.Index) {
    103107            qTree = Tmatch(d, rtop.Next, rtop.LastSibling);
    104108            rtop = Rtop(qTree.Next, qHedge);
     
    108112        } else {
    109113          var rtop = Rtop(qHedge.Next, qTree);
    110           while (rtop.Index < qTree.Next.Index && qTree.Index < rtop.LastSibling.Index) {
     114          while (rtop.Index < int.MaxValue && qTree.Index < rtop.LastSibling.Index) {
    111115            qHedge = Hmatch(d.PreviousSibling, rtop.Next, rtop.LastSibling);
    112116            rtop = Rtop(qHedge.Next, qTree);
     
    123127        return hUntil;
    124128      if (hFrom.Index > hUntil.Index)
    125         return hFrom.Next;
     129        return new NodeInfo { Node = null, Index = int.MaxValue };
    126130      // let u be the highest ancestor of hUntil that has a previous sibling s such that s >= hFrom
    127131      // if no such u exists, then Rtop(hFrom, hUntil) = hUntil. Otherwise, rtop(hFrom, hUntil) = s
    128       if (hUntil.Parent == null)
    129         return hUntil;
    130 
    131132      NodeInfo rtop = null;
    132133      List<NodeInfo> ancestors = hUntil.Ancestors.ToList();
Note: See TracChangeset for help on using the changeset viewer.