Last change
on this file since 15866 was
15771,
checked in by bburlacu, 7 years ago
|
#2895: Add solution skeleton for PushGP with genealogy analysis.
|
File size:
1.6 KB
|
Rev | Line | |
---|
[15771] | 1 | namespace HeuristicLab.Problems.ProgramSynthesis { |
---|
[15341] | 2 | using System.Diagnostics;
|
---|
[15275] | 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;
|
---|
[15334] | 28 | Encoding.MaxCloseParameter = Config.MaxCloseParameter;
|
---|
| 29 | Encoding.CloseBiasLevelParameter = Config.CloseBiasLevelParameter;
|
---|
[15275] | 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 |
|
---|
[15289] | 42 | protected override PushProgram MapIndividual(Individual individual) {
|
---|
[15275] | 43 | var plushVector = individual.PlushVector();
|
---|
| 44 | var program = plushVector.PushProgram;
|
---|
| 45 |
|
---|
[15341] | 46 | if (program == null)
|
---|
| 47 | Debugger.Break();
|
---|
| 48 |
|
---|
[15275] | 49 | return program;
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.