Пример #1
0
 public void InvertedGenerationalDistanceTestEmptyFront()
 {
     double[] point = new double[2];
     point[0] = 0.5;
     point[1] = 0.5;
     double[][] front          = { };
     double[][] referencefront = { point };
     InvertedGenerationalDistance.Calculate(front, referencefront, 1);
 }
Пример #2
0
        public void InvertedGenerationalDistanceTestSinglePoint()
        {
            double[] point = new double[2];
            point[0] = 0;
            point[1] = 0;
            double[][] front  = { point };
            double[]   point2 = new double[2];
            point2[0] = 1;
            point2[1] = 1;
            double[][] referencefront = { point2 };
            double     dist           = InvertedGenerationalDistance.Calculate(front, referencefront, 1);

            Assert.AreEqual(Math.Sqrt(2), dist);
        }
Пример #3
0
        private void Analyze()
        {
            ResultsScatterPlot = new ParetoFrontScatterPlot(solutions.Select(x => x.Fitness).ToArray(), solutions.Select(x => x.Mean.ToArray()).ToArray(), ResultsScatterPlot.ParetoFront, ResultsScatterPlot.Objectives, ResultsScatterPlot.ProblemSize);
            ResultsSolutions   = solutions.Select(x => x.Mean.ToArray()).ToMatrix();

            var problem = Problem as MultiObjectiveTestFunctionProblem;

            if (problem == null)
            {
                return;
            }

            var front = NonDominatedSelect.GetDominatingVectors(solutions.Select(x => x.Fitness), problem.ReferencePoint.CloneAsArray(), Problem.Maximization, true).ToArray();

            if (front.Length == 0)
            {
                return;
            }
            var bounds = problem.Bounds.CloneAsMatrix();

            ResultsCrowding             = Crowding.Calculate(front, bounds);
            ResultsSpacing              = Spacing.Calculate(front);
            ResultsGenerationalDistance = problem.BestKnownFront != null?GenerationalDistance.Calculate(front, problem.BestKnownFront.ToJaggedArray(), 1) : double.NaN;

            ResultsInvertedGenerationalDistance = problem.BestKnownFront != null?InvertedGenerationalDistance.Calculate(front, problem.BestKnownFront.ToJaggedArray(), 1) : double.NaN;

            ResultsHypervolume     = Hypervolume.Calculate(front, problem.ReferencePoint.CloneAsArray(), Problem.Maximization);
            ResultsBestHypervolume = Math.Max(ResultsHypervolume, ResultsBestHypervolume);
            ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume - ResultsBestHypervolume;

            ResultsBestHypervolumeDataLine.Values.Add(ResultsBestHypervolume);
            ResultsHypervolumeDataLine.Values.Add(ResultsHypervolume);
            ResultsCrowdingDataLine.Values.Add(ResultsCrowding);
            ResultsGenerationalDistanceDataLine.Values.Add(ResultsGenerationalDistance);
            ResultsInvertedGenerationalDistanceDataLine.Values.Add(ResultsInvertedGenerationalDistance);
            ResultsSpacingDataLine.Values.Add(ResultsSpacing);
            ResultsHypervolumeDifferenceDataLine.Values.Add(ResultsDifferenceBestKnownHypervolume);

            Problem.Analyze(
                solutions.Select(x => (Optimization.Individual) new SingleEncodingIndividual(Problem.Encoding, new Scope {
                Variables = { new Variable(Problem.Encoding.Name, x.Mean) }
            })).ToArray(),
                solutions.Select(x => x.Fitness).ToArray(),
                Results,
                random);
        }
Пример #4
0
        public void InvertedGenerationalDistanceTestDifferentSizes()
        {
            double[] point = new double[2];
            point[0] = 0;
            point[1] = 0;
            double[] point1 = new double[2];
            point1[0] = 1;
            point1[1] = 0.5;
            double[][] front  = { point, point1 };
            double[]   point2 = new double[2];
            point2[0] = 1;
            point2[1] = 0;
            double[][] referencefront = { point2 };
            double     dist           = InvertedGenerationalDistance.Calculate(front, referencefront, 1);

            Assert.AreEqual(0.5, dist);
        }
Пример #5
0
        public void InvertedGenerationalDistanceTestQuadratic()
        {
            double[] point = new double[2];
            point[0] = 0;
            point[1] = 0;
            double[] point1 = new double[2];
            point1[0] = 0;
            point1[1] = 1;
            double[][] front  = { point, point1 };
            double[]   point2 = new double[2];
            point2[0] = 1;
            point2[1] = 0;
            double[] point3 = new double[2];
            point3[0] = 1;
            point3[1] = 1;
            double[][] referencefront = { point2, point3 };
            double     dist           = InvertedGenerationalDistance.Calculate(front, referencefront, 1);

            Assert.AreEqual(1, dist);
        }