Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PlushPushProblem.cs @ 15289

Last change on this file since 15289 was 15289, checked in by pkimmesw, 7 years ago

#2665 Fixed analyzer, fixed Plush encoding + operators, adpated print evaluation according to McPhee

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