Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Individual/IndividualExtensions.cs @ 17133

Last change on this file since 17133 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.6 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Individual {
2  using System.Collections.Generic;
3  using HeuristicLab.Encodings.IntegerVectorEncoding;
4  using HeuristicLab.Optimization;
5  using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration;
6  using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions;
7  using HeuristicLab.Problems.ProgramSynthesis.Push.SolutionCreator;
8
9  public static class IndividualExtensions {
10
11    public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config) {
12      return individual.IntegerVector().ToPushProgram(config);
13    }
14
15    public static PushProgram ToPushProgram(this IntegerVector vector, IReadOnlyPushConfiguration config) {
16      //var currentIndex = 0;
17      //var close = 0;
18      var expressions = new List<Expression>(vector.Length);
19
20      for (var i = vector.Length - 1; i >= 0; i--) {
21        var index = vector[i];
22
23        if (index == PushSolutionEncoding.End) break;
24        if (index == PushSolutionEncoding.Noop) continue;
25
26        var name = config.EnabledExpressions[index];
27        var expression = ExpressionTable.GetExpression(name);
28
29        //var expression = CodeGeneratorUtils.MapToExpression(
30        //  index,
31        //  random,
32        //  config.ErcOptions,
33        //  config);
34
35        expressions.Add(expression);
36      }
37
38      return new PushProgram(expressions);
39
40      //using (var mapper = IndividualMapper.Create()) {
41      //  return mapper.FromPlush(vector, ref currentIndex, ref close, 0, config, random);
42      //}
43    }
44  }
45}
Note: See TracBrowser for help on using the repository browser.