Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/10/17 11:23:05 (7 years ago)
Author:
pkimmesw
Message:

#2665 Added IsNoop to Expression, Made Expressions storable, Fixed Debugger, Fixed and improved problem data and result visualisation, Added custom ErcOption view, Added problem difficulty to problem data name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushSolution.cs

    r14897 r14952  
    1717    [Storable]
    1818    public readonly IReadOnlyPushConfiguration Config;
    19 
    2019    [Storable]
    2120    public readonly IPushEvaluator Evaluator;
     21    [Storable]
     22    protected readonly bool simplify;
    2223
    23     public readonly PushProgram Program;
     24    public PushProgram Program;
     25
    2426
    2527    public PushSolution(IntegerVector integerVector, double quality, IRandom random, IReadOnlyPushConfiguration config, IPushEvaluator evaluator, bool simplify = false)
     
    3032      Config = config;
    3133      Evaluator = evaluator;
     34      this.simplify = simplify;
    3235
    33       Program = IntegerVector.ToPushProgram(config);
     36      InitProgram();
     37    }
     38
     39    private void InitProgram() {
     40      Program = IntegerVector.ToPushProgram(Config);
    3441
    3542      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);
    3744    }
    3845
    3946    public PushSolution(PushSolution origin, Cloner cloner) : base(origin, cloner) {
     47      IntegerVector = cloner.Clone(origin.IntegerVector);
    4048      Quality = origin.Quality;
    41       IntegerVector = cloner.Clone(origin.IntegerVector);
    4249      Random = cloner.Clone(origin.Random);
    4350      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;
    4454    }
    4555
     
    5161    protected PushSolution(bool deserializing) : base(deserializing) { }
    5262
     63    [StorableHook(HookType.AfterDeserialization)]
     64    // ReSharper disable once UnusedMember.Local
     65    private void AfterDeserialization() {
     66      InitProgram();
     67    }
     68
    5369    public override IDeepCloneable Clone(Cloner cloner) {
    5470      return new PushSolution(this, cloner);
Note: See TracChangeset for help on using the changeset viewer.