Last change
on this file since 17189 was
15771,
checked in by bburlacu, 7 years ago
|
#2895: Add solution skeleton for PushGP with genealogy analysis.
|
File size:
1.4 KB
|
Rev | Line | |
---|
[15771] | 1 | using System.Collections.Generic;
|
---|
| 2 | using HeuristicLab.Encodings.IntegerVectorEncoding;
|
---|
| 3 | using HeuristicLab.Optimization; |
---|
| 4 | |
---|
| 5 | namespace HeuristicLab.Problems.ProgramSynthesis { |
---|
[15189] | 6 | public static class IndividualExtensions {
|
---|
| 7 |
|
---|
[15289] | 8 | public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config) {
|
---|
| 9 | return individual.IntegerVector().ToPushProgram(config);
|
---|
[15189] | 10 | }
|
---|
| 11 |
|
---|
[15289] | 12 | public static PushProgram ToPushProgram(this IntegerVector vector, IReadOnlyPushConfiguration config) {
|
---|
[15189] | 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--) {
|
---|
[15273] | 18 | var index = vector[i];
|
---|
| 19 |
|
---|
[15289] | 20 | if (index == PushSolutionEncoding.End) break;
|
---|
| 21 | if (index == PushSolutionEncoding.Noop) continue;
|
---|
[15273] | 22 |
|
---|
[15289] | 23 | var name = config.EnabledExpressions[index];
|
---|
| 24 | var expression = ExpressionTable.GetExpression(name);
|
---|
[15273] | 25 |
|
---|
[15289] | 26 | //var expression = CodeGeneratorUtils.MapToExpression(
|
---|
| 27 | // index,
|
---|
| 28 | // random,
|
---|
| 29 | // config.ErcOptions,
|
---|
| 30 | // config);
|
---|
[15189] | 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.