Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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();
        }