Changeset 7997 for branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Timestamp:
- 06/13/12 13:20:38 (13 years ago)
- 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 147 147 throw new ArgumentException("Cannot create trees of depth " + maxDepth + " or smaller because of grammar constraints.", "maxDepth"); 148 148 149 150 149 int arity = seedNode.Grammar.GetMaximumSubtreeCount(seedNode.Symbol); 151 150 // Throw an exception if the seedNode happens to be a terminal, since in this case we cannot grow a tree. … … 161 160 .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)) 162 161 .ToList(); 163 var selectedSymbol = possibleSymbols.SelectRandom(random); 162 var weights = possibleSymbols.Select(s => s.InitialFrequency); 163 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 164 164 var tree = selectedSymbol.CreateTreeNode(); 165 165 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); … … 192 192 if (!possibleSymbols.Any()) 193 193 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); 196 196 var tree = selectedSymbol.CreateTreeNode(); 197 197 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
r7479 r7997 160 160 .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)) 161 161 .ToList(); 162 var selectedSymbol = possibleSymbols.SelectRandom(random); 162 var weights = possibleSymbols.Select(s => s.InitialFrequency); 163 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 163 164 var tree = selectedSymbol.CreateTreeNode(); 164 165 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); … … 189 190 if (!possibleSymbols.Any()) 190 191 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); 192 194 var tree = selectedSymbol.CreateTreeNode(); 193 195 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
r7439 r7997 34 34 [StorableClass] 35 35 [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed length")] 36 public class ProbabilisticTreeCreator : SymbolicExpressionTreeCreator,36 public class ProbabilisticTreeCreator : TracingSymbolicExpressionTreeCreator, 37 37 ISymbolicExpressionTreeSizeConstraintOperator, ISymbolicExpressionTreeGrammarBasedOperator { 38 38 private const int MAX_TRIES = 100; -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/TracingSymbolicExpressionTreeCrossover.cs
r7817 r7997 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab. Data;27 using HeuristicLab.EvolutionaryTracking; 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 127 127 // compare the two nodes lists and check the difference (comparing node references so we avoid false functional identity). 128 128 // 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) 131 131 if (nodes0[i] != nodes1[i]) break; 132 132 if (i == min) i = 0; … … 134 134 // add heredity information into the global variables 135 135 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 fragment136 GlobalFragmentMap[Child] = new GenericWrapper<ISymbolicExpressionTreeNode>(nodes1[i]); // map child to the index of its fragment 137 137 return base.Apply(); 138 138 } -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj
r7785 r7997 180 180 <Compile Include="Crossovers\AssortativeSymbolicExpressionTreeCrossover.cs" /> 181 181 <Compile Include="Crossovers\TracingSymbolicExpressionTreeCrossover.cs" /> 182 <Compile Include="GenericWrapper.cs" /> 182 183 <Compile Include="Interfaces\IReadOnlySymbol.cs" /> 183 184 <Compile Include="Interfaces\ISymbolicExpressionGrammar.cs" /> -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj.user
r7800 r7997 7 7 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> 8 8 <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> 10 10 </PropertyGroup> 11 11 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/TracingSymbolicExpressionTreeManipulator.cs
r7792 r7997 21 21 22 22 using System; 23 using System. Linq;23 using System.Collections.Generic; 24 24 using HeuristicLab.Common; 25 25 using HeuristicLab.Core; 26 using HeuristicLab. Data;26 using HeuristicLab.EvolutionaryTracking; 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 109 109 GlobalTraceMap[tree] = new ItemList<IItem> { original }; 110 110 } 111 var nodes0 = tree.IterateNodesBreadth() .ToList();111 var nodes0 = tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>; 112 112 Manipulate(RandomParameter.ActualValue, tree); 113 var nodes1 = tree.IterateNodesBreadth() .ToList();113 var nodes1 = tree.IterateNodesBreadth() as List<ISymbolicExpressionTreeNode>; 114 114 int i, min = Math.Max(nodes0.Count, nodes1.Count); 115 115 for (i = 0; i != min; ++i) 116 116 if (nodes0[i] != nodes1[i]) break; 117 117 if (i == min) i = 0; 118 GlobalFragmentMap[tree] = new IntValue(i);118 GlobalFragmentMap[tree] = new GenericWrapper<ISymbolicExpressionTreeNode>(nodes1[i]); 119 119 120 120 return base.Apply(); -
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Plugin.cs
r7817 r7997 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.78 00")]28 [Plugin("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding","Provides operators and related classes for the symbolic expression tree encoding.", "3.4.2.7817")] 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.