public static string StartGa(FreeTextData data) { var parsedObject = new IoData(data.Points); var inputsList = new List <InputFunction> [parsedObject.Data[0].Output.Count]; for (int i = 0; i < inputsList.Length; i++) { inputsList[i] = new List <InputFunction>(); } foreach (var entry in parsedObject.Data) { for (int i = 0; i < inputsList.Length; i++) { inputsList[i].Add(new InputFunction(entry, i)); } } Task <ExpressionChromosome>[] tasks = new Task <ExpressionChromosome> [inputsList.Length]; for (int i = 0; i < inputsList.Length; i++) { var inputs = inputsList[i].ToArray(); tasks[i] = Task.Run(() => RunGA(inputs)); } try { Task.WaitAll(tasks); } catch (Exception ex) { return(ex.ToString()); } string result = GenerateCSharpFunction(tasks.Select(x => x.Result).ToArray(), parsedObject.Data[0].Input.Count, data.FunctionName, data.VariableNames); return(result); }
public IActionResult StartMutatingFreeText([FromBody] FreeTextData data) { var result = GaService.StartGa(data); return(Json(result)); }