Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Problem/PushEncoding.cs @ 14727

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

#2665 PushGP HL Integration, Views, Parameters

File size: 1.6 KB
Line 
1using System;
2using System.Collections.Generic;
3
4namespace HeuristicLab.Problems.ProgramSynthesis.Push.Problem {
5  using System.Linq;
6
7  using HeuristicLab.Common;
8  using HeuristicLab.Core;
9  using HeuristicLab.Encodings.IntegerVectorEncoding;
10  using HeuristicLab.Optimization;
11  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
12  using HeuristicLab.Problems.ProgramSynthesis.Push.Creator;
13  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
14
15  [Item("PushEncoding", "Describes a push program encoding.")]
16  [StorableClass]
17  public sealed class PushEncoding : Encoding<IPushProgramCreator> {
18
19    [StorableConstructor]
20    public PushEncoding(bool deserializing)
21      : base(deserializing) {
22    }
23
24    public PushEncoding(PushEncoding origin, Cloner cloner)
25      : base(origin, cloner) {
26
27    }
28
29    public override IDeepCloneable Clone(Cloner cloner) {
30      return new PushEncoding(this, cloner);
31    }
32
33    public override void ConfigureOperators(IEnumerable<IOperator> operators) {
34      throw new NotImplementedException();
35    }
36  }
37
38  public static class IndividualExtensionMethods {
39    public static PushProgram PushProgram(this Individual individual, IList<string> enabledExpressions) {
40      return MapToProgram(individual.IntegerVector(), enabledExpressions);
41    }
42
43    private static PushProgram MapToProgram(IntegerVector vector, IList<string> enabledExpressions) {
44      var expressions = vector
45        .Select(i => ExpressionTable.GetExpression(enabledExpressions[i]))
46        .ToArray();
47
48      return new PushProgram(expressions);
49    }
50  }
51}
Note: See TracBrowser for help on using the repository browser.