public static ResultStruct GenerateResult(float[] distances) { ResultStruct result = new ResultStruct(); result.min = distances.Min(); result.max = distances.Max(); result.avg = distances.Average(); float sumOfSquaresOfDifferences = distances.Select(val => (val - result.avg) * (val - result.avg)).Sum(); result.std = Convert.ToSingle(Math.Sqrt(sumOfSquaresOfDifferences / distances.Length)); return(result); }
private void Start(int crossoverSelection, float mutationPossibility) { ResultStruct[] results = new ResultStruct[iteration]; for (int i = 0; i < iteration; i++) { GeneticAlgorithm.Evolution(ref currentPopulation, ref currentDistances, crossoverSelection, mutationPossibility); results[i] = ResultHelper.GenerateResult(currentDistances); } RefreshPicBox(currentPopulation[0]); EvolutionFrm eFrm = new EvolutionFrm(); eFrm.CreateChart(results); eFrm.ShowDialog(); RefreshList(); }