示例#1
0
        private static void GenerateTestResults()
        {
            var referencePareto = LoadReferencePareto();

            NsgaHelper.AssignCrowdingDistances(referencePareto.ResultPoints);
            var filteredIndividuals =
                referencePareto.ResultPoints.OrderByDescending(i => i.CrowdingDistance).Take(150).ToList();
            var nadir = FindNadir(filteredIndividuals);
            var referenceParetoHyperVolume = RInvoker.HyperVolume(filteredIndividuals, nadir);

            var results = LoadResults(OutputsDirectory);

            var counter    = 0;
            var counterMax = results.Count;

            foreach (var result in results)
            {
                try
                {
                    result.HyperVolume      = referenceParetoHyperVolume - RInvoker.HyperVolume(result.ResultPoints, nadir);
                    result.EpsilonIndicator = RInvoker.Epsilon(result.ResultPoints, referencePareto.ResultPoints);
                }
                catch (Exception e)
                {
                    Console.WriteLine("error in caling R script\n " + e.Message);
                }

                counter++;
                Console.WriteLine($"{counter}/{counterMax}");
            }

            WriteToCsv(OutputsDirectory, results);
            SaveAverageValues(results);
            Console.WriteLine("done");
        }
示例#2
0
        private static void AggregateOutputsToPareto()
        {
            var results = LoadResults(OutputsDirectory);

            var groupped =
                results.GroupBy(
                    r =>
                    r.PopulationSize.ToString(CultureInfo.InvariantCulture) + "_" +
                    r.Iterations.ToString(CultureInfo.InvariantCulture) + "_" +
                    r.MutationProbability.ToString(CultureInfo.InvariantCulture)).ToList();

            var paretoFronts = new List <List <Individual> >();

            var counter = 0;

            foreach (var group in groupped)
            {
                Console.WriteLine(counter + " of " + groupped.Count);
                counter++;
                var individuals = ExtractIndividuals(group.ToList());
                if (individuals.Any(i => i.Evaluations.Single(e => e.Type == ObjectiveType.Macro).Score > 400))
                {
                    continue;
                }
                paretoFronts.Add(NsgaHelper.FindFirstFront(individuals));
            }

            var referenceParetoConverted = NsgaHelper.FindFirstFront(paretoFronts.SelectMany(p => p).ToList()).Select(Mapper.CreateResultPoint);

            SaveParetoAsJson(OutputsDirectory, new FrontResult {
                ResultPoints = referenceParetoConverted.ToList()
            });

            Console.WriteLine("Pareto aggregated");
        }