Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/20/18 14:53:51 (6 years ago)
Author:
bwerth
Message:

#2943 worked on MOBasicProblem and MOAnalyzers

Location:
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization

  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveBasicProblem.cs

    r16171 r16310  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.Linq;
    2523using HeuristicLab.Common;
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MetaOptimizers/TimeLimitRun.cs

    r15583 r16310  
    188188          TimeSpan.FromSeconds(15) });
    189189      snapshotTimesIndex = 0;
     190      snapshots = new RunCollection();
    190191      Runs = new RunCollection { OptimizerName = Name };
    191192      Initialize();
     
    199200          TimeSpan.FromSeconds(15) });
    200201      snapshotTimesIndex = 0;
     202      snapshots = new RunCollection();
    201203      Runs = new RunCollection { OptimizerName = Name };
    202204      Initialize();
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/CrowdingCalculator.cs

    r16171 r16310  
    3535  /// Beware that CrowdingCalculator is not normalized for the number of dimensions. A higher number of dimensions normally causes higher CrowdingCalculator values
    3636  /// </summary>
    37   public static class CrowdingCalculator
    38   {
     37  public static class CrowdingCalculator {
    3938
    4039    public static double CalculateCrowding<TP>(IEnumerable<TP> qualities) where TP : IReadOnlyList<double> {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/GenerationalDistanceCalculator.cs

    r16171 r16310  
    2323
    2424#region
    25 
    2625using System;
    2726using System.Collections.Generic;
    2827using System.Linq;
    2928using HeuristicLab.Common;
    30 
    3129#endregion
    3230
     
    4038  public static class GenerationalDistanceCalculator {
    4139    public static double CalculateGenerationalDistance<TP1, TP2>(IEnumerable<TP1> qualities, IEnumerable<TP2> bestKnownFront, double p) where TP1 : IReadOnlyList<double> where TP2 : IReadOnlyList<double> {
    42       if (qualities == null || bestKnownFront == null) throw new ArgumentNullException("Fronts must not be null");
     40      if (qualities == null || bestKnownFront == null) throw new ArgumentNullException(nameof(qualities));
    4341      if (p.IsAlmost(0.0)) throw new ArgumentException("p must not be zero.");
    4442      var mat = bestKnownFront.ToMatrix();
    4543      if (mat.GetLength(0) == 0) throw new ArgumentException("Fronts must not be empty.");
    4644
    47       alglib.kdtree tree;
    48       alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out tree);
     45      alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out var tree);
    4946      var sum = 0.0;
    5047      var summand = new double[1];
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/HypervolumeCalculator.cs

    r16171 r16310  
    2323using System.Linq;
    2424using HeuristicLab.Common;
    25 using HeuristicLab.Optimization;
    2625
    2726namespace HeuristicLab.Optimization {
     
    6463    public static double CalculateHypervolume(double[][] qualities, double[] referencePoint, bool[] maximization){
    6564      qualities = qualities.Where(vec => DominationCalculator.Dominates(vec, referencePoint, maximization, false) == DominationResult.Dominates).ToArray();
    66       if (!qualities.Any()) return 0;//TODO replace with negative computation
     65      if (qualities.Length == 0 ) return 0;//TODO computation for negative hypervolume?
    6766      if (maximization.Length == 2)
    6867        return Calculate2D(qualities, referencePoint, maximization);
     
    7372    }
    7473
     74
     75    /// <summary>
     76    /// Caluclates the Hypervolume for a 2 dimensional problem
     77    /// </summary>
     78    /// <param name="front">All points within the front need to be Non-Dominated and need to dominate the reference point</param>
     79    /// <param name="referencePoint"></param>
     80    /// <param name="maximization"></param>
     81    /// <returns></returns>
    7582    public static double Calculate2D(double[][] front, double[] referencePoint, bool[] maximization) {
    76       if (front == null) throw new ArgumentNullException("Front must not be null.");
     83      if (front == null) throw new ArgumentNullException(nameof(front));
     84      if (referencePoint == null) throw new ArgumentNullException(nameof(referencePoint));
     85      if (maximization == null) throw new ArgumentNullException(nameof(maximization));
    7786      if (!front.Any()) throw new ArgumentException("Front must not be empty.");
    78 
    79       if (referencePoint == null) throw new ArgumentNullException("ReferencePoint must not be null.");
    8087      if (referencePoint.Length != 2) throw new ArgumentException("ReferencePoint must have exactly two dimensions.");
    8188
     
    8794      double sum = 0;
    8895      for (var i = 0; i < set.Length - 1; i++)
    89         sum += Math.Abs((set[i][0] - set[i + 1][0])) * Math.Abs((set[i][1] - referencePoint[1]));
    90      
     96        sum += Math.Abs(set[i][0] - set[i + 1][0]) * Math.Abs(set[i][1] - referencePoint[1]);
    9197      var lastPoint = set[set.Length - 1];
    9298      sum += Math.Abs(lastPoint[0] - referencePoint[0]) * Math.Abs(lastPoint[1] - referencePoint[1]);
     
    112118    }
    113119
     120
     121    //within Stream a number of equality comparisons on double values are performed
     122    //this is intentional and required
    114123    private static double Stream(double[] regionLow, double[] regionUp, List<double[]> front, int split, double cover, int sqrtNoPoints, int objectives) {
    115124      var coverOld = cover;
     
    135144      var piles = new int[coverIndex];
    136145      for (var i = 0; i < coverIndex; i++) {
    137         piles[i] = IsPile(front[i], regionLow, regionUp, objectives);
     146        piles[i] = IsPile(front[i], regionLow, objectives);
    138147        if (piles[i] == -1) {
    139148          allPiles = false;
     
    145154        var trellis = new double[regionUp.Length];
    146155        for (var j = 0; j < trellis.Length; j++) trellis[j] = regionUp[j];
    147         double current = 0;
    148         double next = 0;
     156        double next;
    149157        var i = 0;
    150158        do {
    151           current = front[i][objectives - 1];
     159          var current = front[i][objectives - 1];
    152160          do {
    153161            if (front[i][piles[i]] < trellis[piles[i]]) trellis[piles[i]] = front[i][piles[i]];
     
    176184        } while (bound == -1.0);
    177185
    178         List<double[]> pointsChildLow, pointsChildUp;
    179         pointsChildLow = new List<double[]>();
    180         pointsChildUp = new List<double[]>();
     186        var pointsChildLow = new List<double[]>();
     187        var pointsChildUp = new List<double[]>();
    181188        var regionUpC = new double[regionUp.Length];
    182189        for (var j = 0; j < regionUpC.Length; j++) regionUpC[j] = regionUp[j];
     
    205212      double result = 0;
    206213      var noSummands = BinarayToInt(bs);
    207       int oneCounter; double summand;
    208214      for (uint i = 1; i <= noSummands; i++) {
    209         summand = 1;
     215        double summand = 1;
    210216        IntToBinary(i, bs);
    211         oneCounter = 0;
     217        var oneCounter = 0;
    212218        for (var j = 0; j < objectives - 1; j++) {
    213219          if (bs[j]) {
     
    244250    }
    245251
    246     private static int IsPile(double[] cuboid, double[] regionLow, double[] regionUp, int objectives) {
     252    private static int IsPile(double[] cuboid, double[] regionLow, int objectives) {
    247253      var pile = cuboid.Length;
    248254      for (var i = 0; i < objectives - 1; i++) {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/SpacingCalculator.cs

    r16171 r16310  
    3434
    3535    public static double CalculateSpacing<TP>(IEnumerable<TP> qualities) where TP: IReadOnlyList<double> {
    36       if (qualities == null) throw new ArgumentException("Front must not be null.");
     36      if (qualities == null) throw new ArgumentNullException(nameof(qualities));
    3737      var l = qualities.ToList();
    3838      if (l.Count == 0) throw new ArgumentException("Front must not be empty.");
     
    4040
    4141      var mat = l.ToMatrix();
    42       alglib.kdtree tree;
    43       alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out tree);
     42      alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out var tree);
    4443      var summand = new double[2];
    4544      var dists = new List<double>();
     
    5150      return dists.StandardDeviationPop();
    5251    }
    53 
    54    
    5552  }
    5653}
Note: See TracChangeset for help on using the changeset viewer.