Changeset 18082 for branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators
- Timestamp:
- 11/15/21 16:18:39 (3 years ago)
- Location:
- branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators
- Files:
-
- 2 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 }
Note: See TracChangeset
for help on using the changeset viewer.