/// <summary> /// Displays the selections and the user can choose the one of them. /// </summary> /// <param name="problemConfig">Problem controller.</param> /// <returns>Selected selection.</returns> public static ISelection SetSelection(IProblemConfig problemConfig) { var operators = problemConfig.PossibleSelections(); var name = PrintSelectedOperators(operators, "Selection"); return(problemConfig.CreateSelection(name)); }
/// <summary> /// Displays the crossovers and the user can choose the one of them. /// The selection is made by a serial number. /// </summary> /// <param name="problemConfig">Problem controller.</param> /// <returns>Selected crossover.</returns> public static IXover SetXover(IProblemConfig problemConfig) { var operators = problemConfig.PossibleXovers(); var name = PrintSelectedOperators(operators, "Crossover"); return(problemConfig.CreateXover(name)); }
/// <summary> /// Displays the mutations and the user can choose the one of them. /// The selection is made by a serial number. /// </summary> /// <param name="problemConfig">Problem controller.</param> /// <returns>Selected mutation.</returns> public static IMutation SetMutation(IProblemConfig problemConfig) { var mutations = problemConfig.PossibleMutations(); var mutName = PrintSelectedOperators(mutations, "Mutation"); return(problemConfig.CreateMutation(mutName)); }
/// <summary> /// Displays the elitizmuses and the user can choose the one of them. /// The selection is made by a serial number. /// </summary> /// <param name="problemConfig">Problem controller.</param> /// <returns>Selected elitizmus.</returns> public static IElite SetElite(IProblemConfig problemConfig) { var operators = problemConfig.PossibleElities(); var name = PrintSelectedOperators(operators, "Elitizmus"); var paramter = SetFloat("Elite percentage", 0, 1); return(problemConfig.CreateElite(name, paramter)); }
/// <summary> /// Displays the terminations and the user can choose the one of them. /// </summary> /// <param name="problemConfig">Problem controller.</param> /// <returns>Selected termination.</returns> public static ITermination SetTermination(IProblemConfig problemConfig) { var operators = problemConfig.PossibleTerminations(); // possible terminations var name = PrintSelectedOperators(operators, "Termination"); // end point of the condition var parameter = SetPositiveIntParameter("Termination parameter", 1); return(problemConfig.CreateTermination(name, parameter)); }
/// <summary> /// Console logger. /// </summary> /// <param name="eva">evolutionary alg.</param> /// <param name="consoleProblemConfig">Problem represention</param> /// <param name="logRate">logger rate</param> public void SetGenerationInfoLog(IEVA eva, IProblemConfig consoleProblemConfig, int logRate) { eva.CurrentGenerationInfo += delegate { var bestIndividual = eva.BestIndividual; Console.WriteLine("Generations: {0}", eva.CurrentGenerationsNumber); Console.WriteLine("Fitness: {0,10}", bestIndividual.Fitness); Console.WriteLine("Time: {0}", eva.TimeEvolving); var speed = eva.TimeEvolving.TotalSeconds / eva.CurrentGenerationsNumber; Console.WriteLine("Speed (gen/sec): {0:0.0000}", speed); var best = consoleProblemConfig.ShowBestIndividual(bestIndividual, logRate); var fit = eva.CurrentGenerationsNumber + ";" + (bestIndividual.Fitness); var elapsedTimeSpeed = eva.CurrentGenerationsNumber + ";" + speed; var allInfo = eva.CurrentGenerationsNumber + ";" + (bestIndividual.Fitness) + ";" + eva.TimeEvolving + ";" + speed; consoleProblemConfig.SetGenerationInfo(fit, elapsedTimeSpeed, allInfo); }; }