Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2895_PushGP_GenealogyAnalysis/HeuristicLab.Problems.ProgramSynthesis/Push/Individual/IndividualExtensions.cs @ 17511

Last change on this file since 17511 was 15771, checked in by bburlacu, 7 years ago

#2895: Add solution skeleton for PushGP with genealogy analysis.

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