namespace HeuristicLab.Problems.ProgramSynthesis.Push.Individual { using System.Collections.Generic; using HeuristicLab.Core; using HeuristicLab.Encodings.IntegerVectorEncoding; using HeuristicLab.Optimization; using HeuristicLab.Problems.ProgramSynthesis.Push.Configuration; using HeuristicLab.Problems.ProgramSynthesis.Push.Expressions; using HeuristicLab.Problems.ProgramSynthesis.Push.Generators.CodeGenerator; using HeuristicLab.Problems.ProgramSynthesis.Push.SolutionCreator; public static class IndividualExtensions { public static PushProgram ToPushProgram(this Individual individual, IReadOnlyPushConfiguration config, IRandom random) { return individual.IntegerVector().ToPushProgram(config, random); } public static PushProgram ToPushProgram(this IntegerVector vector, IReadOnlyPushConfiguration config, IRandom random) { //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; // skip noops if (index == PushSolutionEncoding.Noop) continue; 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); //} } } }