namespace HeuristicLab.Problems.ProgramSynthesis.Push.Individual { using System.Collections.Generic; using HeuristicLab.Encodings.IntegerVectorEncoding; using HeuristicLab.Optimization; using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration; using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions; using HeuristicLab.Problems.ProgramSynthesis.Push.SolutionCreator; public static class IndividualExtensions { public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config) { return individual.IntegerVector().ToPushProgram(config); } public static PushProgram ToPushProgram(this IntegerVector vector, IReadOnlyPushConfiguration config) { //var currentIndex = 0; //var close = 0; var expressions = new List(vector.Length); for (var i = vector.Length - 1; i >= 0; i--) { var index = vector[i]; if (index == PushSolutionEncoding.End) break; if (index == PushSolutionEncoding.Noop) continue; var name = config.EnabledExpressions[index]; var expression = ExpressionTable.GetExpression(name); //var expression = CodeGeneratorUtils.MapToExpression( // index, // random, // config.ErcOptions, // config); expressions.Add(expression); } return new PushProgram(expressions); //using (var mapper = IndividualMapper.Create()) { // return mapper.FromPlush(vector, ref currentIndex, ref close, 0, config, random); //} } } }