Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7514


Ignore:
Timestamp:
02/24/12 10:58:22 (12 years ago)
Author:
bburlacu
Message:

#1772: Merged latest trunk changes to SymbolicExpressionTreeEncoding. Deleted unneeded obj folder.

Location:
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4

    • Property svn:ignore set to
      bin
      obj
      HeuristicLabEncodingsSymbolicExpressionTreeEncodingPlugin.cs
      *.user
      *.vs10x
      Plugin.cs
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/TracingSymbolicExpressionTreeCrossover.cs

    r7479 r7514  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 using TreeCacheType = HeuristicLab.Core.ItemList<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree>;
    30 using CloneMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree,
    31                                                       HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree>;
    32 using TraceMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree,
    33                                                       HeuristicLab.Core.IItemArray<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree>>;
     29using CloneMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItem>;
     30using TraceMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItemList<HeuristicLab.Core.IItem>>;
    3431
    3532namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    8077      Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(ParentsParameterName, "The parent symbolic expression trees which should be crossed."));
    8178      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(ChildParameterName, "The child symbolic expression tree resulting from the crossover."));
    82       Parameters.Add(new LookupParameter<ItemDictionary<ISymbolicExpressionTree, ISymbolicExpressionTree>>(GlobalCloneMapParameterName, "A global map keeping track of trees and their clones (made during selection)."));
    83       Parameters.Add(new LookupParameter<ItemDictionary<ISymbolicExpressionTree, IItemArray<ISymbolicExpressionTree>>>(GlobalTraceMapParameterName, "A global cache containing tracing info."));
     79      Parameters.Add(new LookupParameter<CloneMapType>(GlobalCloneMapParameterName, "A global map keeping track of trees and their clones (made during selection)."));
     80      Parameters.Add(new LookupParameter<TraceMapType>(GlobalTraceMapParameterName, "A global cache containing tracing info."));
    8481    }
    8582
     
    9188        var gScope = ExecutionContext.Scope;
    9289        while (gScope.Parent != null) gScope = gScope.Parent;
    93         gScope.Variables.Add(new Variable(GlobalTraceMapParameterName, new ItemDictionary<ISymbolicExpressionTree, IItemArray<ISymbolicExpressionTree>>()));
     90        gScope.Variables.Add(new Variable(GlobalTraceMapParameterName, new TraceMapType()));
    9491      }
    95       var originalParents = new ItemArray<ISymbolicExpressionTree>(Parents.Select(x => GlobalCloneMap[x]));
    96       // prevent incestuous crossover (an individual mating with itself)
    97       if (originalParents[0] == originalParents[1]) {
    98         Child = Parents[0];
    99         return base.Apply();
    100       }
     92      var originalParents = new ItemList<IItem>(Parents.Select(x => GlobalCloneMap[x]));
    10193      ISymbolicExpressionTree result = Cross(Random, Parents[0], Parents[1]);
    102 
    10394      Child = result;
    10495      GlobalTraceMap.Add(Child, originalParents);
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj.user

    r7479 r7514  
    1717    <StartProgram>C:\Users\bburlacu\Desktop\HL-Core\trunk\sources\bin\HeuristicLab 3.3.exe</StartProgram>
    1818  </PropertyGroup>
     19  <PropertyGroup>
     20    <ProjectView>ProjectFiles</ProjectView>
     21  </PropertyGroup>
    1922</Project>
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs

    r7439 r7514  
    2828  [StorableClass]
    2929  [Item("ChangeNodeTypeManipulation", "Selects a random tree node and changes the symbol.")]
    30   public sealed class ChangeNodeTypeManipulation : SymbolicExpressionTreeManipulator {
     30  public sealed class ChangeNodeTypeManipulation : TracingSymbolicExpressionTreeManipulator {
    3131    [StorableConstructor]
    3232    private ChangeNodeTypeManipulation(bool deserializing) : base(deserializing) { }
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs

    r7439 r7514  
    3131  [StorableClass]
    3232  [Item("OnePointShaker", "Selects a random node with local parameters and manipulates the selected node.")]
    33   public sealed class OnePointShaker : SymbolicExpressionTreeManipulator {
     33  public sealed class OnePointShaker : TracingSymbolicExpressionTreeManipulator {
    3434    private const string ShakingFactorParameterName = "ShakingFactor";
    3535    #region parameter properties
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs

    r7439 r7514  
    3030  [StorableClass]
    3131  [Item("ReplaceBranchManipulation", "Selects a branch of the tree randomly and replaces it with a newly initialized branch (using PTC2).")]
    32   public sealed class ReplaceBranchManipulation : SymbolicExpressionTreeManipulator, ISymbolicExpressionTreeSizeConstraintOperator {
     32  public sealed class ReplaceBranchManipulation : TracingSymbolicExpressionTreeManipulator, ISymbolicExpressionTreeSizeConstraintOperator {
    3333    private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength";
    3434    private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth";
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/TracingSymbolicExpressionTreeManipulator.cs

    r7479 r7514  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    24 using HeuristicLab.Data;
    2525using HeuristicLab.Parameters;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27
     28using CloneMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItem>;
     29using TraceMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItemList<HeuristicLab.Core.IItem>>;
    2730
    2831namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     
    3437  public abstract class TracingSymbolicExpressionTreeManipulator : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeManipulator {
    3538    private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree";
    36     private const string GlobalTraceCacheParameterName = "GlobalTraceCache";
    37     private const string GlobalTreeMapParameterName = "GlobalTreeMap";
     39    private const string GlobalTraceMapParameterName = "GlobalTraceMap";
     40    private const string GlobalCloneMapParameterName = "GlobalCloneMap";
    3841
    3942    #region Parameter Properties
     
    4144      get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; }
    4245    }
    43     public LookupParameter<ItemDictionary<ISymbolicExpressionTree, ISymbolicExpressionTree>> GlobalTreeMapParameter {
    44       get {
    45         return (LookupParameter<ItemDictionary<ISymbolicExpressionTree, ISymbolicExpressionTree>>)Parameters[GlobalTreeMapParameterName];
    46       }
     46    public LookupParameter<CloneMapType> GlobalCloneMapParameter {
     47      get { return (LookupParameter<CloneMapType>)Parameters[GlobalCloneMapParameterName]; }
     48    }
     49    public LookupParameter<TraceMapType> GlobalTraceMapParameter {
     50      get { return (LookupParameter<TraceMapType>)Parameters[GlobalTraceMapParameterName]; }
    4751    }
    4852    #endregion
     
    5256      get { return SymbolicExpressionTreeParameter.ActualValue; }
    5357    }
    54     public ItemDictionary<ISymbolicExpressionTree, ISymbolicExpressionTree> GlobalTreeMap {
    55       get { return GlobalTreeMapParameter.ActualValue; }
     58    public CloneMapType GlobalCloneMap {
     59      get { return GlobalCloneMapParameter.ActualValue; }
     60    }
     61    public TraceMapType GlobalTraceMap {
     62      get { return GlobalTraceMapParameter.ActualValue; }
    5663    }
    5764    #endregion
     
    6370      : base() {
    6471      Parameters.Add(new LookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression tree on which the operator should be applied."));
    65       Parameters.Add(new LookupParameter<ItemDictionary<ISymbolicExpressionTree, ISymbolicExpressionTree>>(GlobalTreeMapParameterName, "A global map keeping track of trees and their clones (made during selection)."));
     72      Parameters.Add(new LookupParameter<CloneMapType>(GlobalCloneMapParameterName, "A global map keeping track of trees and their clones (made during selection)."));
     73      Parameters.Add(new LookupParameter<TraceMapType>(GlobalTraceMapParameterName, "A global cache containing tracing info."));
    6674    }
    6775
     
    6977      ISymbolicExpressionTree tree = SymbolicExpressionTreeParameter.ActualValue;
    7078
     79      if (GlobalTraceMap == null) {
     80        var gScope = ExecutionContext.Scope;
     81        while (gScope.Parent != null) gScope = gScope.Parent;
     82        gScope.Variables.Add(new Variable(GlobalTraceMapParameterName, new TraceMapType()));
     83      }
     84      if (GlobalTraceMap.ContainsKey(tree)) {
     85        // tree was affected by crossover before mutation
     86        // if the tree to be manipulated is already a product of crossover (in the current reproduction phase), then there exists no relationship with the original "parent".
     87        // In order to preserve information, a tree clone is created before mutation and added to the trace map.
     88        var clone = (IItem)tree.Clone();
     89        GlobalTraceMap[clone] = GlobalTraceMap[tree];
     90        GlobalTraceMap[tree] = new ItemList<IItem> { clone };
     91      } else {
     92        var original = GlobalCloneMap[tree];
     93        GlobalTraceMap[tree] = new ItemList<IItem> { original };
     94      }
    7195      Manipulate(RandomParameter.ActualValue, tree);
    7296
    73       //AddTraceInfoToGlobalCache();
    74 
    7597      return base.Apply();
    76     }
    77 
    78     private void AddTraceInfoToGlobalCache() {
    79       var globalScope = ExecutionContext.Scope;
    80       while (globalScope.Parent != null) globalScope = globalScope.Parent;
    81 
    82       Variable globalTraceCache;
    83       if (!globalScope.Variables.ContainsKey(GlobalTraceCacheParameterName)) {
    84         globalTraceCache = new Variable(GlobalTraceCacheParameterName, new ItemDictionary<ISymbolicExpressionTree, IItemArray<ISymbolicExpressionTree>>());
    85         globalScope.Variables.Add(globalTraceCache);
    86       } else
    87         globalTraceCache = (Variable)globalScope.Variables[GlobalTraceCacheParameterName];
    88 
    89       var traceCache = (ItemDictionary<ISymbolicExpressionTree, IItemArray<ISymbolicExpressionTree>>)globalTraceCache.Value;
    90 
    91       traceCache.Add(SymbolicExpressionTree, new ItemArray<ISymbolicExpressionTree>(new[] { GlobalTreeMap[SymbolicExpressionTree] }));
    9298    }
    9399
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs

    r7479 r7514  
    2626
    2727namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    28   [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7439")]
     28  [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7479")]
    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.