Changeset 17686


Ignore:
Timestamp:
07/19/20 14:52:56 (4 weeks ago)
Author:
dleko
Message:

#2825 Add Generational Distance and Inverted Generational Distance to result page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/NSGA3.cs

    r17679 r17686  
    8080        private const string GeneratedReferencePointsResultName = "Generated Reference Points";
    8181        private const string CurrentGenerationResultName = "Generations";
     82        private const string GenerationalDistanceResultName = "Generational Distance";
     83        private const string InvertedGenerationalDistanceResultName = "Inverted Generational Distance";
    8284        private const string ScatterPlotResultName = "Scatter Plot";
    8385        private const string CurrentFrontResultName = "Pareto Front"; // Do not touch this
     
    174176            get { return (IntValue)Results[CurrentGenerationResultName].Value; }
    175177            set { Results[CurrentGenerationResultName].Value = value; }
     178        }
     179
     180        public DoubleValue ResultsGenerationalDistance
     181        {
     182            get { return (DoubleValue)Results[GenerationalDistanceResultName].Value;}
     183            set { Results[GenerationalDistanceResultName].Value = value; }
     184        }
     185
     186        public DoubleValue ResultsInvertedGenerationalDistance
     187        {
     188            get { return (DoubleValue)Results[InvertedGenerationalDistanceResultName].Value; }
     189            set { Results[InvertedGenerationalDistanceResultName].Value = value; }
    176190        }
    177191
     
    269283            Results.Add(new Result(CurrentFrontResultName, "The Pareto Front", new DoubleMatrix()));
    270284            Results.Add(new Result(CurrentGenerationResultName, "The current generation", new IntValue(1)));
     285            Results.Add(new Result(GenerationalDistanceResultName, "The generational distance to an optimal pareto front defined in the Problem", new DoubleValue(double.NaN)));
     286            Results.Add(new Result(InvertedGenerationalDistanceResultName, "The inverted generational distance to an optimal pareto front defined in the Problem", new DoubleValue(double.NaN)));
    271287            Results.Add(new Result(ScatterPlotResultName, "A scatterplot displaying the evaluated solutions and (if available) the analytically optimal front", new ParetoFrontScatterPlot()));
    272288
     
    324340            ResultsScatterPlot = new ParetoFrontScatterPlot(solutions.Select(x => x.Fitness).ToArray(), solutions.Select(x => x.Chromosome.ToArray()).ToArray(), ResultsScatterPlot.ParetoFront, ResultsScatterPlot.Objectives, ResultsScatterPlot.ProblemSize);
    325341            ResultsSolutions = solutions.Select(s => s.Chromosome.ToArray()).ToMatrix();
     342
     343            var problem = Problem as MultiObjectiveTestFunctionProblem;
     344            if (problem == null) return;
     345
     346            ResultsGenerationalDistance = new DoubleValue(problem.BestKnownFront != null ? GenerationalDistance.Calculate(solutions.Select(s => s.Fitness), problem.BestKnownFront.ToJaggedArray(), 1) : double.NaN);
     347            ResultsInvertedGenerationalDistance = new DoubleValue(problem.BestKnownFront != null ? InvertedGenerationalDistance.Calculate(solutions.Select(s => s.Fitness), problem.BestKnownFront.ToJaggedArray(), 1) : double.NaN);
     348
    326349            Problem.Analyze(
    327350                solutions.Select(s => (Individual)new SingleEncodingIndividual(Problem.Encoding, new Scope { Variables = { new Variable(Problem.Encoding.Name, s.Chromosome) } })).ToArray(),
Note: See TracChangeset for help on using the changeset viewer.