Changeset 14952 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushSolution.cs
- Timestamp:
- 05/10/17 11:23:05 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushSolution.cs
r14897 r14952 17 17 [Storable] 18 18 public readonly IReadOnlyPushConfiguration Config; 19 20 19 [Storable] 21 20 public readonly IPushEvaluator Evaluator; 21 [Storable] 22 protected readonly bool simplify; 22 23 23 public readonly PushProgram Program; 24 public PushProgram Program; 25 24 26 25 27 public PushSolution(IntegerVector integerVector, double quality, IRandom random, IReadOnlyPushConfiguration config, IPushEvaluator evaluator, bool simplify = false) … … 30 32 Config = config; 31 33 Evaluator = evaluator; 34 this.simplify = simplify; 32 35 33 Program = IntegerVector.ToPushProgram(config); 36 InitProgram(); 37 } 38 39 private void InitProgram() { 40 Program = IntegerVector.ToPushProgram(Config); 34 41 35 42 if (simplify) 36 Program = Simplifier.Simplifier.Simplify(Program, p => Evaluator.EvaluateTraining(config, p, random).TotalQuality);43 Program = Simplifier.Simplifier.Simplify(Program, Config, p => Evaluator.EvaluateTraining(Config, p, Random).TotalQuality); 37 44 } 38 45 39 46 public PushSolution(PushSolution origin, Cloner cloner) : base(origin, cloner) { 47 IntegerVector = cloner.Clone(origin.IntegerVector); 40 48 Quality = origin.Quality; 41 IntegerVector = cloner.Clone(origin.IntegerVector);42 49 Random = cloner.Clone(origin.Random); 43 50 Config = cloner.Clone(origin.Config); 51 Evaluator = cloner.Clone(origin.Evaluator); 52 Program = origin.Program; // push programs are immutable like all expressions 53 simplify = origin.simplify; 44 54 } 45 55 … … 51 61 protected PushSolution(bool deserializing) : base(deserializing) { } 52 62 63 [StorableHook(HookType.AfterDeserialization)] 64 // ReSharper disable once UnusedMember.Local 65 private void AfterDeserialization() { 66 InitProgram(); 67 } 68 53 69 public override IDeepCloneable Clone(Cloner cloner) { 54 70 return new PushSolution(this, cloner);
Note: See TracChangeset
for help on using the changeset viewer.