Changeset 14410 for branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs
- Timestamp:
- 11/24/16 16:38:20 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/ExpressionTemplate.cs
r14409 r14410 32 32 protected readonly string label; 33 33 34 public abstract Expression Instantiate(IRandom random );34 public abstract Expression Instantiate(IRandom random, bool sampleWithRepetition = false); 35 35 36 36 protected ExpressionTemplate(string label, Func<IEnumerable<double>, double> transform) { … … 62 62 } 63 63 64 public override Expression Instantiate(IRandom random ) {64 public override Expression Instantiate(IRandom random, bool sampleWithRepetition = false) { 65 65 var arity = (int)Math.Round(arityDistribution.NextDouble()); 66 var args = arguments.SampleProportional(random, arity, arguments.Select(x => x.Item2)).Select(x => x.Item1); 66 var weights = arguments.Select(x => x.Item2); 67 var args = sampleWithRepetition 68 ? arguments.SampleProportional(random, arity, weights).Select(x => x.Item1) 69 : arguments.SampleProportionalWithoutRepetition(random, arity, weights).Select(x => x.Item1); 67 70 return Expression.Function(label, transform, args); 68 71 } … … 75 78 } 76 79 77 public override Expression Instantiate(IRandom random ) {80 public override Expression Instantiate(IRandom random, bool sampleWithRepetition = false) { 78 81 var args = arguments.SampleProportional(random, arity, arguments.Select(x => x.Item2)).Select(x => x.Item1); 79 82 return Expression.Function(label, transform, args);
Note: See TracChangeset
for help on using the changeset viewer.