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); }
private void InitResults() { Results.Add(new Result(IterationsResultName, "The number of gererations evaluated", new IntValue(0))); Results.Add(new Result(EvaluationsResultName, "The number of function evaltions performed", new IntValue(0))); Results.Add(new Result(HypervolumeResultName, "The hypervolume of the current front considering the Referencepoint defined in the Problem", new DoubleValue(0.0))); Results.Add(new Result(BestHypervolumeResultName, "The best hypervolume of the current run considering the Referencepoint defined in the Problem", new DoubleValue(0.0))); Results.Add(new Result(BestKnownHypervolumeResultName, "The best knwon hypervolume considering the Referencepoint defined in the Problem", new DoubleValue(double.NaN))); Results.Add(new Result(DifferenceToBestKnownHypervolumeResultName, "The difference between the current and the best known hypervolume", new DoubleValue(double.NaN))); Results.Add(new Result(GenerationalDistanceResultName, "The generational distance to an optimal pareto front defined in the Problem", new DoubleValue(double.NaN))); Results.Add(new Result(InvertedGenerationalDistanceResultName, "The inverted generational distance to an optimal pareto front defined in the Problem", new DoubleValue(double.NaN))); Results.Add(new Result(CrowdingResultName, "The average crowding value for the current front (excluding infinities)", new DoubleValue(0.0))); Results.Add(new Result(SpacingResultName, "The spacing for the current front (excluding infinities)", new DoubleValue(0.0))); var table = new DataTable("QualityIndicators"); table.Rows.Add(new DataRow(BestHypervolumeResultName)); table.Rows.Add(new DataRow(HypervolumeResultName)); table.Rows.Add(new DataRow(CrowdingResultName)); table.Rows.Add(new DataRow(GenerationalDistanceResultName)); table.Rows.Add(new DataRow(InvertedGenerationalDistanceResultName)); table.Rows.Add(new DataRow(DifferenceToBestKnownHypervolumeResultName)); table.Rows.Add(new DataRow(SpacingResultName)); Results.Add(new Result(TimetableResultName, "Different quality meassures in a timeseries", table)); Results.Add(new Result(CurrentFrontResultName, "The current front", new DoubleMatrix())); Results.Add(new Result(ScatterPlotResultName, "A scatterplot displaying the evaluated solutions and (if available) the analytically optimal front", new ParetoFrontScatterPlot())); var problem = Problem as MultiObjectiveTestFunctionProblem; if (problem == null) { return; } if (problem.BestKnownFront != null) { ResultsBestKnownHypervolume = Hypervolume.Calculate(problem.BestKnownFront.ToJaggedArray(), problem.TestFunction.ReferencePoint(problem.Objectives), Problem.Maximization); ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume; } ResultsScatterPlot = new ParetoFrontScatterPlot(new double[0][], new double[0][], problem.BestKnownFront.ToJaggedArray(), problem.Objectives, problem.ProblemSize); }