Changeset 7514 for branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Timestamp:
- 02/24/12 10:58:22 (13 years ago)
- Location:
- branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Files:
-
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
-
Property
svn:ignore
set to
bin
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding merged eligible /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTree 3219-3222
-
Property
svn:ignore
set to
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
-
Property
svn:ignore
set to
bin
obj
HeuristicLabEncodingsSymbolicExpressionTreeEncodingPlugin.cs
*.user
*.vs10x
Plugin.cs
-
Property
svn:ignore
set to
-
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/TracingSymbolicExpressionTreeCrossover.cs
r7479 r7514 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 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>>; 29 using CloneMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItem>; 30 using TraceMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItemList<HeuristicLab.Core.IItem>>; 34 31 35 32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 80 77 Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(ParentsParameterName, "The parent symbolic expression trees which should be crossed.")); 81 78 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.")); 84 81 } 85 82 … … 91 88 var gScope = ExecutionContext.Scope; 92 89 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())); 94 91 } 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])); 101 93 ISymbolicExpressionTree result = Cross(Random, Parents[0], Parents[1]); 102 103 94 Child = result; 104 95 GlobalTraceMap.Add(Child, originalParents); -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj.user
r7479 r7514 17 17 <StartProgram>C:\Users\bburlacu\Desktop\HL-Core\trunk\sources\bin\HeuristicLab 3.3.exe</StartProgram> 18 18 </PropertyGroup> 19 <PropertyGroup> 20 <ProjectView>ProjectFiles</ProjectView> 21 </PropertyGroup> 19 22 </Project> -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs
r7439 r7514 28 28 [StorableClass] 29 29 [Item("ChangeNodeTypeManipulation", "Selects a random tree node and changes the symbol.")] 30 public sealed class ChangeNodeTypeManipulation : SymbolicExpressionTreeManipulator {30 public sealed class ChangeNodeTypeManipulation : TracingSymbolicExpressionTreeManipulator { 31 31 [StorableConstructor] 32 32 private ChangeNodeTypeManipulation(bool deserializing) : base(deserializing) { } -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs
r7439 r7514 31 31 [StorableClass] 32 32 [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 { 34 34 private const string ShakingFactorParameterName = "ShakingFactor"; 35 35 #region parameter properties -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs
r7439 r7514 30 30 [StorableClass] 31 31 [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 { 33 33 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength"; 34 34 private const string MaximumSymbolicExpressionTreeDepthParameterName = "MaximumSymbolicExpressionTreeDepth"; -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/TracingSymbolicExpressionTreeManipulator.cs
r7479 r7514 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 using HeuristicLab.Data;25 25 using HeuristicLab.Parameters; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 using CloneMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItem>; 29 using TraceMapType = HeuristicLab.Core.ItemDictionary<HeuristicLab.Core.IItem, HeuristicLab.Core.IItemList<HeuristicLab.Core.IItem>>; 27 30 28 31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 34 37 public abstract class TracingSymbolicExpressionTreeManipulator : SymbolicExpressionTreeOperator, ISymbolicExpressionTreeManipulator { 35 38 private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree"; 36 private const string GlobalTrace CacheParameterName = "GlobalTraceCache";37 private const string Global TreeMapParameterName = "GlobalTreeMap";39 private const string GlobalTraceMapParameterName = "GlobalTraceMap"; 40 private const string GlobalCloneMapParameterName = "GlobalCloneMap"; 38 41 39 42 #region Parameter Properties … … 41 44 get { return (ILookupParameter<ISymbolicExpressionTree>)Parameters[SymbolicExpressionTreeParameterName]; } 42 45 } 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]; } 47 51 } 48 52 #endregion … … 52 56 get { return SymbolicExpressionTreeParameter.ActualValue; } 53 57 } 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; } 56 63 } 57 64 #endregion … … 63 70 : base() { 64 71 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.")); 66 74 } 67 75 … … 69 77 ISymbolicExpressionTree tree = SymbolicExpressionTreeParameter.ActualValue; 70 78 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 } 71 95 Manipulate(RandomParameter.ActualValue, tree); 72 96 73 //AddTraceInfoToGlobalCache();74 75 97 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 } else87 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] }));92 98 } 93 99 -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs
r7479 r7514 26 26 27 27 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 28 [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.74 39")]28 [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7479")] 29 29 [PluginFile("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")]
Note: See TracChangeset
for help on using the changeset viewer.