Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 17230

Ignore:
Timestamp:
09/03/19 15:50:35 (4 years ago)
Message:

#2521: add multi-objective analysis to all multi-objective encoding-base problems

Location:
branches/2521_ProblemRefactoring
Files:
10 edited

Unmodified
Removed
• ## branches/2521_ProblemRefactoring/HeuristicLab.Analysis.Views/3.3/ParetoFrontScatterPlotViewOfT.cs

 r17229 } private static Point2D[] CreatePoints(IList front, T[] solutions, int xDimIndex, int yDimIndex) { private static Point2D[] CreatePoints(IReadOnlyList front, T[] solutions, int xDimIndex, int yDimIndex) { if (front == null || front.Count == 0) return new Point2D[0];

• ## branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorMultiObjectiveProblem.cs

 r17226 public override void Analyze(BinaryVector[] individuals, double[][] qualities, ResultCollection results, IRandom random) { base.Analyze(individuals, qualities, results, random); // TODO: Calculate Pareto front and add to results var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(individuals, qualities, Maximization); var plot = new ParetoFrontScatterPlot(fronts, individuals, qualities, Objectives, BestKnownFront); results.AddOrUpdateResult("Pareto Front Scatter Plot", plot); }
• ## branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorMultiObjectiveProblem.cs

 r16948 public override void Analyze(IntegerVector[] individuals, double[][] qualities, ResultCollection results, IRandom random) { base.Analyze(individuals, qualities, results, random); // TODO: Calculate Pareto front and add to results var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(individuals, qualities, Maximization); var plot = new ParetoFrontScatterPlot(fronts, individuals, qualities, Objectives, BestKnownFront); results.AddOrUpdateResult("Pareto Front Scatter Plot", plot); }

 r17225 base.Analyze(individuals, qualities, results, random); var result = DominationCalculator.CalculateBestParetoFront(individuals, qualities, Maximization); // TODO: Add results var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(individuals, qualities, Maximization); var plot = new ParetoFrontScatterPlot(fronts, individuals, qualities, Objectives, BestKnownFront); results.AddOrUpdateResult("Pareto Front Scatter Plot", plot); }
• ## branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationMultiObjectiveProblem.cs

 r16948 public override void Analyze(Permutation[] individuals, double[][] qualities, ResultCollection results, IRandom random) { base.Analyze(individuals, qualities, results, random); // TODO: Calculate Pareto front and add to results var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(individuals, qualities, Maximization); var plot = new ParetoFrontScatterPlot(fronts, individuals, qualities, Objectives, BestKnownFront); results.AddOrUpdateResult("Pareto Front Scatter Plot", plot); }
• ## branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorMultiObjectiveProblem.cs

 r16949 public override void Analyze(RealVector[] individuals, double[][] qualities, ResultCollection results, IRandom random) { base.Analyze(individuals, qualities, results, random); // TODO: Calculate Pareto front and add to results var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(individuals, qualities, Maximization); var plot = new ParetoFrontScatterPlot(fronts, individuals, qualities, Objectives, BestKnownFront); results.AddOrUpdateResult("Pareto Front Scatter Plot", plot); }
• ## branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeMultiObjectiveProblem.cs

 r17229 using System.Linq; using HEAL.Attic; using HeuristicLab.Analysis; using HeuristicLab.Common; using HeuristicLab.Core; IRandom random) { base.Analyze(trees, qualities, results, random); var front = DominationCalculator.CalculateBestParetoFront(trees, qualities, Maximization); // TODO: Calculate Pareto front and add to results var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(trees, qualities, Maximization); var plot = new ParetoFrontScatterPlot(fronts, trees, qualities, Objectives, BestKnownFront); results.AddOrUpdateResult("Pareto Front Scatter Plot", plot); }
• ## branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/MultiObjective/DominationCalculator.cs

 r17226 using System; using System.Collections.Generic; using System.Linq; using HEAL.Attic; /// /// Calculates all pareto fronts by returning the index of the parameters in each front. /// The first in the list is the best front. /// The fast non-dominated sorting algorithm is used as described in /// Deb, K., Pratap, A., Agarwal, S., and Meyarivan, T. (2002). /// A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II. /// IEEE Transactions on Evolutionary Computation, 6(2), 182-197. /// /// /// When there are plateaus in the fitness landscape several solutions might have exactly /// the same fitness vector. In this case parameter /// can be set to true to avoid plateaus becoming too attractive for the search process. /// /// The solutions of the population. /// The qualities resp. fitness for each solution. /// The objective in each dimension. /// Whether solutions of exactly equal quality should dominate one another. /// A sorted list of the pareto fronts where each front contains the indices of the and . public static List> CalculateAllParetoFrontsIndices(T[] solutions, double[][] qualities, bool[] maximization, bool dominateOnEqualQualities = true) { return CalculateAllParetoFrontsIndices(solutions, qualities, maximization, out var rank, dominateOnEqualQualities); } /// /// Calculates all pareto fronts by returning the index of the parameters in each front. /// The first in the list is the best front. /// The fast non-dominated sorting algorithm is used as described in /// Deb, K., Pratap, A., Agarwal, S., and Meyarivan, T. (2002). /// A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II. /// IEEE Transactions on Evolutionary Computation, 6(2), 182-197. /// /// /// When there are plateaus in the fitness landscape several solutions might have exactly /// the same fitness vector. In this case parameter /// can be set to true to avoid plateaus becoming too attractive for the search process. /// /// The solutions of the population. /// The qualities resp. fitness for each solution. /// The objective in each dimension. /// The rank of each of the solutions, corresponds to the front it is put in. /// Whether solutions of exactly equal quality should dominate one another. /// A sorted list of the pareto fronts where each front contains the indices of the and . public static List> CalculateAllParetoFrontsIndices(T[] solutions, double[][] qualities, bool[] maximization, out int[] rank, bool dominateOnEqualQualities = true) { var populationSize = solutions.Length; var dominatedIndividuals = Enumerable.Range(0, qualities.Length).Select(x => new List()).ToArray(); var dominationCounter = new int[populationSize]; rank = new int[populationSize]; var fronts = new List>(); fronts.Add(CalculateBestFrontIndices(solutions, qualities, maximization, dominateOnEqualQualities, populationSize, dominatedIndividuals, dominationCounter, rank)); var i = 0; while (i < fronts.Count && fronts[i].Count > 0) { var nextFront = new List(); foreach (var p in fronts[i]) { if (dominatedIndividuals[p].Count > 0) { for (var k = 0; k < dominatedIndividuals[p].Count; k++) { var dominatedIndividual = dominatedIndividuals[p][k]; dominationCounter[dominatedIndividual] -= 1; if (dominationCounter[dominatedIndividual] == 0) { rank[dominatedIndividual] = i + 1; nextFront.Add(dominatedIndividual); } } } } i += 1; fronts.Add(nextFront); } return fronts; } private static List CalculateBestFrontIndices(T[] solutions, double[][] qualities, bool[] maximization, bool dominateOnEqualQualities, int populationSize, List[] dominatedIndividuals, int[] dominationCounter, int[] rank) { var front = new List(); for (var pI = 0; pI < populationSize - 1; pI++) { var p = solutions[pI]; for (var qI = pI + 1; qI < populationSize; qI++) { var test = Dominates(qualities[pI], qualities[qI], maximization, dominateOnEqualQualities); if (test == DominationResult.Dominates) { dominatedIndividuals[pI].Add(qI); dominationCounter[qI] += 1; } else if (test == DominationResult.IsDominated) { dominationCounter[pI] += 1; dominatedIndividuals[qI].Add(pI); } if (pI == populationSize - 2 && qI == populationSize - 1 && dominationCounter[qI] == 0) { rank[qI] = 0; front.Add(qI); } } if (dominationCounter[pI] == 0) { rank[pI] = 0; front.Add(pI); } } return front; } /// /// Calculates the domination result of two solutions which are given in form /// of their quality resp. fitness vector.
• ## branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs

 r17229 } var fronts = DominationCalculator.CalculateAllParetoFronts(individuals.ToArray(), qualities.Select(x => x.ToArray()).ToArray(), testFunction.Maximization(objectives), out var rank); ScatterPlotResultParameter.ActualValue = new ParetoFrontScatterPlot( fronts.Select(x => x.Select(y => y.Item2).ToArray()).ToArray(), fronts.Select(x => x.Select(y => y.Item1).ToArray()).ToArray(), optimalFront, objectives); var q = qualities.Select(x => x.ToArray()).ToArray(); var s = individuals.ToArray(); var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(s, q, testFunction.Maximization(objectives), out var rank); ScatterPlotResultParameter.ActualValue = new ParetoFrontScatterPlot(fronts, s, q, objectives, optimalFront); return base.Apply(); }
Note: See TracChangeset for help on using the changeset viewer.