Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/13/12 13:20:38 (13 years ago)
Author:
bburlacu
Message:

#1772: New analyzer: SymbolicExpressionTreeRelativeLengthAnalyzer. Rewrote the SymbolicExpressionTreeFragmentsAnalyzer, added generic wrapper to wrap HL objects as items.

Location:
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs

    r7479 r7997  
    147147        throw new ArgumentException("Cannot create trees of depth " + maxDepth + " or smaller because of grammar constraints.", "maxDepth");
    148148
    149 
    150149      int arity = seedNode.Grammar.GetMaximumSubtreeCount(seedNode.Symbol);
    151150      // Throw an exception if the seedNode happens to be a terminal, since in this case we cannot grow a tree.
     
    161160          .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i))
    162161          .ToList();
    163         var selectedSymbol = possibleSymbols.SelectRandom(random);
     162        var weights = possibleSymbols.Select(s => s.InitialFrequency);
     163        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
    164164        var tree = selectedSymbol.CreateTreeNode();
    165165        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
     
    192192        if (!possibleSymbols.Any())
    193193          throw new InvalidOperationException("No symbols are available for the tree.");
    194 
    195         var selectedSymbol = possibleSymbols.SelectRandom(random);
     194        var weights = possibleSymbols.Select(s => s.InitialFrequency);
     195        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
    196196        var tree = selectedSymbol.CreateTreeNode();
    197197        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs

    r7479 r7997  
    160160          .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i))
    161161          .ToList();
    162         var selectedSymbol = possibleSymbols.SelectRandom(random);
     162        var weights = possibleSymbols.Select(s => s.InitialFrequency);
     163        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
    163164        var tree = selectedSymbol.CreateTreeNode();
    164165        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
     
    189190        if (!possibleSymbols.Any())
    190191          throw new InvalidOperationException("No symbols are available for the tree.");
    191         var selectedSymbol = possibleSymbols.SelectRandom(random);
     192        var weights = possibleSymbols.Select(s => s.InitialFrequency);
     193        var selectedSymbol = possibleSymbols.SelectRandom(weights, random);
    192194        var tree = selectedSymbol.CreateTreeNode();
    193195        if (tree.HasLocalParameters) tree.ResetLocalParameters(random);
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs

    r7439 r7997  
    3434  [StorableClass]
    3535  [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed length")]
    36   public class ProbabilisticTreeCreator : SymbolicExpressionTreeCreator,
     36  public class ProbabilisticTreeCreator : TracingSymbolicExpressionTreeCreator,
    3737    ISymbolicExpressionTreeSizeConstraintOperator, ISymbolicExpressionTreeGrammarBasedOperator {
    3838    private const int MAX_TRIES = 100;
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/TracingSymbolicExpressionTreeCrossover.cs

    r7817 r7997  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Data;
     27using HeuristicLab.EvolutionaryTracking;
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    127127      // compare the two nodes lists and check the difference (comparing node references so we avoid false functional identity).
    128128      // if no difference is found, then it is assumed that the whole tree was swapped with itself (it can happen), so the index is 0
    129       int i = 0, min = Math.Min(nodes0.Count, nodes1.Count);
    130       for (; i != min; ++i)
     129      int i, min = Math.Min(nodes0.Count, nodes1.Count);
     130      for (i = 0; i != min; ++i)
    131131        if (nodes0[i] != nodes1[i]) break;
    132132      if (i == min) i = 0;
     
    134134      // add heredity information into the global variables
    135135      GlobalTraceMap[Child] = originalParents; // map child to its corresponding parents from the previous generation
    136       GlobalFragmentMap[Child] = new IntValue(i); // map child to the index of its fragment
     136      GlobalFragmentMap[Child] = new GenericWrapper<ISymbolicExpressionTreeNode>(nodes1[i]); // map child to the index of its fragment
    137137      return base.Apply();
    138138    }
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj

    r7785 r7997  
    180180    <Compile Include="Crossovers\AssortativeSymbolicExpressionTreeCrossover.cs" />
    181181    <Compile Include="Crossovers\TracingSymbolicExpressionTreeCrossover.cs" />
     182    <Compile Include="GenericWrapper.cs" />
    182183    <Compile Include="Interfaces\IReadOnlySymbol.cs" />
    183184    <Compile Include="Interfaces\ISymbolicExpressionGrammar.cs" />
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj.user

    r7800 r7997  
    77  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
    88    <StartAction>Program</StartAction>
    9     <StartProgram>C:\Users\Bogdan\Desktop\Trunk\sources\bin\HeuristicLab 3.3.exe</StartProgram>
     9    <StartProgram>C:\Users\bburlacu\Desktop\HL-Core\Trunk\sources\bin\HeuristicLab 3.3.exe</StartProgram>
    1010  </PropertyGroup>
    1111  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/TracingSymbolicExpressionTreeManipulator.cs

    r7792 r7997  
    2121
    2222using System;
    23 using System.Linq;
     23using System.Collections.Generic;
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Data;
     26using HeuristicLab.EvolutionaryTracking;
    2727using HeuristicLab.Parameters;
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    109109        GlobalTraceMap[tree] = new ItemList<IItem> { original };
    110110      }
    111       var nodes0 = tree.IterateNodesBreadth().ToList();
     111      var nodes0 = tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
    112112      Manipulate(RandomParameter.ActualValue, tree);
    113       var nodes1 = tree.IterateNodesBreadth().ToList();
     113      var nodes1 = tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>;
    114114      int i, min = Math.Max(nodes0.Count, nodes1.Count);
    115115      for (i = 0; i != min; ++i)
    116116        if (nodes0[i] != nodes1[i]) break;
    117117      if (i == min) i = 0;
    118       GlobalFragmentMap[tree] = new IntValue(i);
     118      GlobalFragmentMap[tree] = new GenericWrapper<ISymbolicExpressionTreeNode>(nodes1[i]);
    119119
    120120      return base.Apply();
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs

    r7817 r7997  
    2626
    2727namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    28   [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7800")]
     28  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7817")]
    2929  [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
Note: See TracChangeset for help on using the changeset viewer.