Last change
on this file since 15289 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
|
Rev | Line | |
---|
[15189] | 1 | namespace 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;
|
---|
[15273] | 7 | using HeuristicLab.Problems.ProgramSynthesis.Push.SolutionCreator;
|
---|
[15189] | 8 |
|
---|
| 9 | public static class IndividualExtensions {
|
---|
| 10 |
|
---|
[15289] | 11 | public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config) {
|
---|
| 12 | return individual.IntegerVector().ToPushProgram(config);
|
---|
[15189] | 13 | }
|
---|
| 14 |
|
---|
[15289] | 15 | public static PushProgram ToPushProgram(this IntegerVector vector, IReadOnlyPushConfiguration config) {
|
---|
[15189] | 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--) {
|
---|
[15273] | 21 | var index = vector[i];
|
---|
| 22 |
|
---|
[15289] | 23 | if (index == PushSolutionEncoding.End) break;
|
---|
| 24 | if (index == PushSolutionEncoding.Noop) continue;
|
---|
[15273] | 25 |
|
---|
[15289] | 26 | var name = config.EnabledExpressions[index];
|
---|
| 27 | var expression = ExpressionTable.GetExpression(name);
|
---|
[15273] | 28 |
|
---|
[15289] | 29 | //var expression = CodeGeneratorUtils.MapToExpression(
|
---|
| 30 | // index,
|
---|
| 31 | // random,
|
---|
| 32 | // config.ErcOptions,
|
---|
| 33 | // config);
|
---|
[15189] | 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.