Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2895_PushGP_GenealogyAnalysis/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PlushPushProblem.cs @ 17511

Last change on this file since 17511 was 15771, checked in by bburlacu, 7 years ago

#2895: Add solution skeleton for PushGP with genealogy analysis.

File size: 1.6 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis {
2  using System.Diagnostics;
3  using System.Linq;
4
5  using HeuristicLab.Common;
6  using HeuristicLab.Optimization;
7  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8
9  [StorableClass]
10  public abstract class PlushPushProblem : PushProblemBase<PlushEncoding> {
11    protected PlushPushProblem(IPushEvaluator evaluator)
12      : base(evaluator) {
13      InitEncoding();
14      InitOperators();
15    }
16
17    protected PlushPushProblem(bool deserializing)
18      : base(deserializing) {
19    }
20
21    protected PlushPushProblem(PushProblemBase<PlushEncoding> original, Cloner cloner)
22      : base(original, cloner) {
23    }
24
25    private void InitEncoding() {
26      Encoding.ErcOptionsParameter = Config.ErcOptionsParameter;
27      Encoding.InstructionsParameter = Config.InstructionsParameter;
28      Encoding.MaxCloseParameter = Config.MaxCloseParameter;
29      Encoding.CloseBiasLevelParameter = Config.CloseBiasLevelParameter;
30    }
31
32    private void InitOperators() {
33      if (!Operators.OfType<PushExpressionFrequencyAnalyzer>().Any()) {
34        Operators.Add(new PushExpressionFrequencyAnalyzer());
35      }
36
37      if (!Operators.OfType<IndividualZeroErrorAnalyzer>().Any()) {
38        Operators.Add(new IndividualZeroErrorAnalyzer());
39      }
40    }
41
42    protected override PushProgram MapIndividual(Individual individual) {
43      var plushVector = individual.PlushVector();
44      var program = plushVector.PushProgram;
45
46      if (program == null)
47        Debugger.Break();
48
49      return program;
50    }
51  }
52}
Note: See TracBrowser for help on using the repository browser.