Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2665 Testet Problems, Improved Performance

File size: 1.8 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Problem {
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  using HeuristicLab.Problems.ProgramSynthesis.Push.Analyzer;
9  using HeuristicLab.Problems.ProgramSynthesis.Push.Encoding;
10  using HeuristicLab.Problems.ProgramSynthesis.Push.Evaluator;
11  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
12
13  [StorableClass]
14  public abstract class PlushPushProblem : PushProblemBase<PlushEncoding> {
15    protected PlushPushProblem(IPushEvaluator evaluator)
16      : base(evaluator) {
17      InitEncoding();
18      InitOperators();
19    }
20
21    protected PlushPushProblem(bool deserializing)
22      : base(deserializing) {
23    }
24
25    protected PlushPushProblem(PushProblemBase<PlushEncoding> original, Cloner cloner)
26      : base(original, cloner) {
27    }
28
29    private void InitEncoding() {
30      Encoding.ErcOptionsParameter = Config.ErcOptionsParameter;
31      Encoding.InstructionsParameter = Config.InstructionsParameter;
32      Encoding.MaxCloseParameter = Config.MaxCloseParameter;
33      Encoding.CloseBiasLevelParameter = Config.CloseBiasLevelParameter;
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      if (program == null)
51        Debugger.Break();
52
53      return program;
54    }
55  }
56}
Note: See TracBrowser for help on using the repository browser.