Changeset 14733 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators
- Timestamp:
- 03/08/17 11:57:42 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Generators/CodeGenerator.cs
r14727 r14733 19 19 public static class CodeGenerator { 20 20 21 public static PushProgram RandomProgram(int maxPoints, IRandom random = null, IReadonlyPush GpConfiguration pushGpConfiguration = null, IDictionary<string, Expression> customExpressions = null) {21 public static PushProgram RandomProgram(int maxPoints, IRandom random = null, IReadonlyPushConfiguration pushGpConfiguration = null, IDictionary<string, Expression> customExpressions = null) { 22 22 var code = RandomCode(maxPoints, random, pushGpConfiguration, customExpressions); 23 23 … … 25 25 } 26 26 27 public static ExecExpandExpression RandomExpandExpression(int maxPoints, IRandom random = null, IReadonlyPush GpConfiguration pushGpConfiguration = null, IDictionary<string, Expression> customExpressions = null) {27 public static ExecExpandExpression RandomExpandExpression(int maxPoints, IRandom random = null, IReadonlyPushConfiguration pushGpConfiguration = null, IDictionary<string, Expression> customExpressions = null) { 28 28 var program = RandomProgram(maxPoints, random, pushGpConfiguration, customExpressions); 29 29 … … 31 31 } 32 32 33 public static IEnumerable<Expression> RandomCode(int maxPoints, IRandom random = null, IReadonlyPush GpConfiguration pushGpConfiguration = null, IDictionary<string, Expression> customExpressions = null) {33 public static IEnumerable<Expression> RandomCode(int maxPoints, IRandom random = null, IReadonlyPushConfiguration pushGpConfiguration = null, IDictionary<string, Expression> customExpressions = null) { 34 34 if (maxPoints == 0) 35 35 return new Expression[0]; 36 36 37 37 random = random ?? new FastRandom(); 38 pushGpConfiguration = pushGpConfiguration ?? new Push GpConfiguration();38 pushGpConfiguration = pushGpConfiguration ?? new PushConfiguration(); 39 39 40 40 if (pushGpConfiguration.EnabledExpressions.Count == 0) … … 46 46 } 47 47 48 private static IEnumerable<Expression> RandomCodeWithSize(int points, IRandom random, IReadonlyPush GpConfiguration pushGpConfiguration, IDictionary<string, Expression> customExpressions = null) {48 private static IEnumerable<Expression> RandomCodeWithSize(int points, IRandom random, IReadonlyPushConfiguration pushGpConfiguration, IDictionary<string, Expression> customExpressions = null) { 49 49 if (points == 1) { 50 50 … … 70 70 } 71 71 72 private static Expression CreateExpression(IRandom random, IReadonlyPush GpConfiguration pushGpConfiguration, IDictionary<string, Expression> customExpressions = null) {72 private static Expression CreateExpression(IRandom random, IReadonlyPushConfiguration pushGpConfiguration, IDictionary<string, Expression> customExpressions = null) { 73 73 var customCount = customExpressions == null ? 0 : customExpressions.Count - 1; 74 74 var index = random.Next(0, pushGpConfiguration.EnabledExpressions.Count + customCount - 1); … … 85 85 } 86 86 87 private static Expression CreateRandomErcExpression(IRandom random, IReadonlyPush GpConfiguration pushGpConfiguration) {87 private static Expression CreateRandomErcExpression(IRandom random, IReadonlyPushConfiguration pushGpConfiguration) { 88 88 var value = random.Next(0, 3); 89 89
Note: See TracChangeset
for help on using the changeset viewer.