Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/15/21 16:18:39 (3 years ago)
Author:
pfleck
Message:

#3040: Added the ISymbolicDataAnalysisExpressionManipulator and necessary code analogously to the ISymbolicDataAnalysisExpressionCrossover.

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  
    114114    }
    115115
     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
    116132    protected override void Operators_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<ISymbolicExpressionTreeManipulator>> e) {
    117133      base.Operators_ItemsReplaced(sender, e);
  • branches/3040_VectorBasedGP/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SymbolicExpressionTreeArchitectureManipulator.cs

    r17180 r18082  
    6262    }
    6363
    64     protected override sealed void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {
     64    public sealed override void Manipulate(IRandom random, ISymbolicExpressionTree symbolicExpressionTree) {
    6565      ModifyArchitecture(random, symbolicExpressionTree, MaximumFunctionDefinitions, MaximumFunctionArguments);
    6666    }
Note: See TracChangeset for help on using the changeset viewer.