Changeset 15273 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Individual
- Timestamp:
- 07/19/17 12:55:58 (8 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Individual
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Individual/IndividualExtensions.cs
r15189 r15273 6 6 using HeuristicLab.Optimization; 7 7 using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration; 8 using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool;9 8 using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions; 10 9 using HeuristicLab.Problems.ProgramSynthesis.Push.Generators.CodeGenerator; 11 using HeuristicLab. Random;10 using HeuristicLab.Problems.ProgramSynthesis.Push.SolutionCreator; 12 11 13 12 public static class IndividualExtensions { 14 public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config, ObjectPool<IRandom> randomPool) {15 return individual.IntegerVector().ToPushProgram(config, randomPool);16 }17 18 public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config) {19 return individual.IntegerVector().ToPushProgram(config);20 }21 13 22 14 public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config, IRandom random) { 23 15 return individual.IntegerVector().ToPushProgram(config, random); 24 }25 26 public static PushProgram ToPushProgram(this IntegerVector vector, IReadOnlyPushConfiguration config, ObjectPool<IRandom> randomPool) {27 var random = randomPool.Allocate();28 var seed = vector.GetSeed();29 30 random.Reset(seed);31 var program = vector.ToPushProgram(config, random);32 randomPool.Free(random);33 34 return program;35 }36 37 public static PushProgram ToPushProgram(this IntegerVector vector, IReadOnlyPushConfiguration config) {38 var seed = (uint)vector.GetSeed();39 return vector.ToPushProgram(config, new MersenneTwister(seed));40 }41 42 public static int GetSeed(this IntegerVector vector) {43 var seed = 17;44 for (var i = 0; i < vector.Length; i++)45 seed = seed * 23 + vector[i];46 return seed;47 16 } 48 17 … … 53 22 54 23 for (var i = vector.Length - 1; i >= 0; i--) { 55 var expression = CodeGeneratorUtils.CreateExpressionOrErc( 56 vector[i], 24 var index = vector[i]; 25 26 if (index == PushSolutionEncoding.End) 27 break; 28 29 // skip noops 30 if (index == PushSolutionEncoding.Noop) 31 continue; 32 33 var expression = CodeGeneratorUtils.MapToExpression( 34 index, 57 35 random, 58 config.E nabledExpressions,59 config .ErcOptions);36 config.ErcOptions, 37 config); 60 38 61 39 expressions.Add(expression); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Individual/InduvidualMapper.cs
r15189 r15273 39 39 40 40 for (; currentIndex < vector.Length; currentIndex++) { 41 var expression = CodeGeneratorUtils. CreateExpressionOrErc(41 var expression = CodeGeneratorUtils.MapToExpression( 42 42 vector[currentIndex] % config.EnabledExpressions.Count, 43 43 random, 44 config.E nabledExpressions,45 config .ErcOptions);44 config.ErcOptions, 45 config); 46 46 47 47 var expressionType = expression.GetType();
Note: See TracChangeset
for help on using the changeset viewer.