- Timestamp:
- 11/15/21 16:18:39 (3 years ago)
- Location:
- branches/3040_VectorBasedGP
- Files:
-
- 4 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/MultiSymbolicExpressionTreeArchitectureManipulator.cs
r17180 r18082 114 114 } 115 115 116 public void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) { 117 double sum = Operators.CheckedItems.Sum(o => Probabilities[o.Index]); 118 if (sum.IsAlmost(0)) throw new InvalidOperationException(Name + ": All selected operators have zero probability."); 119 double r = random.NextDouble() * sum; 120 sum = 0; 121 int index = -1; 122 foreach (var indexedItem in Operators.CheckedItems) { 123 sum += Probabilities[indexedItem.Index]; 124 if (sum > r) { 125 index = indexedItem.Index; 126 break; 127 } 128 } 129 Operators[index].Manipulate(random, symbolicExpressionTree); 130 } 131 116 132 protected override void Operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<ISymbolicExpressionTreeManipulator>> e) { 117 133 base.Operators_ItemsReplaced(sender, e); -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SymbolicExpressionTreeArchitectureManipulator.cs
r17180 r18082 62 62 } 63 63 64 p rotected override sealedvoid Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {64 public sealed override void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) { 65 65 ModifyArchitecture(random, symbolicExpressionTree, MaximumFunctionDefinitions, MaximumFunctionArguments); 66 66 } -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeManipulator.cs
r17180 r18082 22 22 using HeuristicLab.Optimization; 23 23 using HEAL.Attic; 24 using HeuristicLab.Core; 24 25 25 26 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 29 30 /// </summary> 30 31 public interface ISymbolicExpressionTreeManipulator : ISymbolicExpressionTreeOperator, IManipulator { 32 //ILookupParameter<ISymbolicExpressionTree> ParentParameter { get; } 33 void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree); 31 34 } 32 35 } -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ChangeNodeTypeManipulation.cs
r17180 r18082 41 41 } 42 42 43 p rotectedoverride void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {43 public override void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) { 44 44 ChangeNodeType(random, symbolicExpressionTree); 45 45 } -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/FullTreeShaker.cs
r17180 r18082 54 54 } 55 55 56 p rotectedoverride void Manipulate(IRandom random, ISymbolicExpressionTree tree) {56 public override void Manipulate(IRandom random, ISymbolicExpressionTree tree) { 57 57 tree.Root.ForEachNodePostfix(node => { 58 58 if (node.HasLocalParameters) { -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/MultiSymbolicExpressionTreeManipulator.cs
r17180 r18082 81 81 CheckedItemList<ISymbolicExpressionTreeManipulator> checkedItemList = new CheckedItemList<ISymbolicExpressionTreeManipulator>(); 82 82 checkedItemList.AddRange(list.OrderBy(op => op.Name)); 83 Operators = checkedItemList.AsReadOnly(); 83 //Operators = checkedItemList.AsReadOnly(); 84 Operators = checkedItemList; 84 85 Operators_ItemsAdded(this, new CollectionItemsChangedEventArgs<IndexedItem<ISymbolicExpressionTreeManipulator>>(Operators.CheckedItems)); 85 86 … … 89 90 public override IDeepCloneable Clone(Cloner cloner) { 90 91 return new MultiSymbolicExpressionTreeManipulator(this, cloner); 92 } 93 94 public void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) { 95 double sum = Operators.CheckedItems.Sum(o => Probabilities[o.Index]); 96 if (sum.IsAlmost(0)) throw new InvalidOperationException(Name + ": All selected operators have zero probability."); 97 double r = random.NextDouble() * sum; 98 sum = 0; 99 int index = -1; 100 foreach (var indexedItem in Operators.CheckedItems) { 101 sum += Probabilities[indexedItem.Index]; 102 if (sum > r) { 103 index = indexedItem.Index; 104 break; 105 } 106 } 107 Operators[index].Manipulate(random, symbolicExpressionTree); 91 108 } 92 109 -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs
r17180 r18082 56 56 } 57 57 58 p rotectedoverride void Manipulate(IRandom random, ISymbolicExpressionTree tree) {58 public override void Manipulate(IRandom random, ISymbolicExpressionTree tree) { 59 59 OnePointShaker.Shake(random, tree, ShakingFactor); 60 60 } -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/RemoveBranchManipulation.cs
r17180 r18082 66 66 } 67 67 68 p rotectedoverride void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {68 public override void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) { 69 69 RemoveRandomBranch(random, symbolicExpressionTree, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 70 70 } -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/ReplaceBranchManipulation.cs
r17180 r18082 65 65 } 66 66 67 p rotectedoverride void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {67 public override void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) { 68 68 ReplaceRandomBranch(random, symbolicExpressionTree, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 69 69 } -
branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/SymbolicExpressionTreeManipulator.cs
r17180 r18082 46 46 } 47 47 48 p rotectedabstract void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree);48 public abstract void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree); 49 49 } 50 50 } -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r17930 r18082 174 174 <Compile Include="Converters\TreeToAutoDiffTermConverter.cs" /> 175 175 <Compile Include="Creators\SymbolicDataAnalysisExpressionBalancedTreeCreator.cs" /> 176 <Compile Include="Mutators\MultiSymbolicDataAnalysisExpressionManipulator.cs" /> 177 <Compile Include="Interfaces\ISymbolicDataAnalysisExpressionManipulator.cs" /> 178 <Compile Include="Mutators\SymbolicDataAnalysisExpressionManipulator.cs" /> 176 179 <Compile Include="Crossovers\SymbolicDataAnalysisExpressionDiversityPreservingCrossover.cs" /> 177 180 <Compile Include="Formatters\InfixExpressionFormatter.cs" /> … … 201 204 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeVectorInterpreter.cs" /> 202 205 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs" /> 206 <Compile Include="Mutators\SubVectorImprovementManipulator.cs" /> 203 207 <Compile Include="Selectors\DiversitySelector.cs" /> 204 208 <Compile Include="SymbolicDataAnalysisExpressionTreeAverageSimilarityCalculator.cs" /> … … 454 458 </ProjectReference> 455 459 </ItemGroup> 460 <ItemGroup /> 456 461 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 457 462 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs
r17456 r18082 229 229 foreach (var op in ApplicationManager.Manager.GetInstances<ISymbolicDataAnalysisExpressionCrossover<T>>()) 230 230 operators.Add(op); 231 foreach (var op in ApplicationManager.Manager.GetInstances<ISymbolicDataAnalysisExpressionManipulator<T>>()) 232 operators.Add(op); 231 233 232 234 operators.Add(new SymbolicExpressionSymbolFrequencyAnalyzer()); … … 357 359 op.EvaluatorParameter.ActualName = EvaluatorParameter.Name; 358 360 } 361 foreach (var op in operators.OfType<ISymbolicDataAnalysisExpressionManipulator<T>>()) { 362 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name; 363 op.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 364 op.EvaluationPartitionParameter.ActualName = FitnessCalculationPartitionParameter.Name; 365 op.RelativeNumberOfEvaluatedSamplesParameter.ActualName = RelativeNumberOfEvaluatedSamplesParameter.Name; 366 op.EvaluatorParameter.ActualName = EvaluatorParameter.Name; 367 } 359 368 } 360 369
Note: See TracChangeset
for help on using the changeset viewer.