Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/21/18 09:18:49 (6 years ago)
Author:
bwerth
Message:

#2943 worked on MOBasicProblem - added Interfaces;reworked MOCalculators; several minor changes

Location:
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ.cs

    r15583 r16171  
    4242
    4343    protected override double[] GetReferencePoint(int objectives) {
    44       double[] rp = new double[objectives];
    45       for (int i = 0; i < objectives; i++) {
     44      var rp = new double[objectives];
     45      for (var i = 0; i < objectives; i++) {
    4646        rp[i] = 11;
    4747      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ1.cs

    r15583 r16171  
    4848        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4949      }
    50       double[] res = new double[objectives];
    51       int k = r.Length - objectives + 1;
     50      var res = new double[objectives];
     51      var k = r.Length - objectives + 1;
    5252      double g = 0;
    5353
    54       for (int i = r.Length - k; i < r.Length; i++) {
     54      for (var i = r.Length - k; i < r.Length; i++) {
    5555        g += (r[i] - 0.5) * (r[i] - 0.5) - Math.Cos(20.0 * Math.PI * (r[i] - 0.5));
    5656      };
     
    5858      g *= 100;
    5959
    60       for (int i = 0; i < objectives; i++) {
     60      for (var i = 0; i < objectives; i++) {
    6161        res[i] = 0.5 * (1.0 + g);
    62         for (int j = 0; j < objectives - i - 1; ++j)
     62        for (var j = 0; j < objectives - i - 1; ++j)
    6363          res[i] *= (r[j]);
    6464        if (i > 0)
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ2.cs

    r15583 r16171  
    4848      }
    4949
    50       double[] res = new double[objectives];
     50      var res = new double[objectives];
    5151
    5252      //calculate g(Xm)
    5353      double g = 0;
    54       for (int i = objectives; i < r.Length; i++) {
    55         double d = r[i] - 0.5;
     54      for (var i = objectives; i < r.Length; i++) {
     55        var d = r[i] - 0.5;
    5656        g += d * d;
    5757      }
    5858
    5959      //calculating f0...fM-1
    60       for (int i = 0; i < objectives; i++) {
    61         double f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);
    62         for (int j = 0; j < objectives - i - 1; j++) {
     60      for (var i = 0; i < objectives; i++) {
     61        var f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);
     62        for (var j = 0; j < objectives - i - 1; j++) {
    6363          f *= Math.Cos(r[j] * Math.PI / 2);
    6464        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ3.cs

    r15583 r16171  
    4747        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4848      }
    49       double[] res = new double[objectives];
     49      var res = new double[objectives];
    5050
    5151      //calculate g(Xm)
    5252      double sum = 0;
    53       int length = r.Length - objectives + 1;
    54       for (int i = r.Length - length; i < r.Length; i++) {
    55         double d = r[i] - 0.5;
     53      var length = r.Length - objectives + 1;
     54      for (var i = r.Length - length; i < r.Length; i++) {
     55        var d = r[i] - 0.5;
    5656        sum += d * d - Math.Cos(20 * Math.PI * d);
    5757      }
    58       double g = 100 * (length + sum);
     58      var g = 100 * (length + sum);
    5959
    6060      //calculating f0...fM-1
    61       for (int i = 0; i < objectives; i++) {
    62         double f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);
    63         for (int j = 0; j < objectives - i - 1; j++) {
     61      for (var i = 0; i < objectives; i++) {
     62        var f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);
     63        for (var j = 0; j < objectives - i - 1; j++) {
    6464          f *= Math.Cos(r[j] * Math.PI / 2);
    6565        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ4.cs

    r15583 r16171  
    4747        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4848      }
    49       double[] res = new double[objectives];
     49      var res = new double[objectives];
    5050
    5151      //calculate g(Xm)
    5252      double g = 0;
    53       for (int i = objectives; i < r.Length; i++) {
    54         double d = r[i] - 0.5;
     53      for (var i = objectives; i < r.Length; i++) {
     54        var d = r[i] - 0.5;
    5555        g += d * d;
    5656      }
    5757
    5858      //calculating f0...fM-1
    59       for (int i = 0; i < objectives; i++) {
    60         double f = i == 0 ? 1 : (Math.Sin(Math.Pow(r[objectives - i - 1], 100) * Math.PI / 2)) * (1 + g);
    61         for (int j = 0; j < objectives - i - 1; j++) {
     59      for (var i = 0; i < objectives; i++) {
     60        var f = i == 0 ? 1 : (Math.Sin(Math.Pow(r[objectives - i - 1], 100) * Math.PI / 2)) * (1 + g);
     61        for (var j = 0; j < objectives - i - 1; j++) {
    6262          f *= Math.Cos(Math.Pow(r[j], 100) * Math.PI / 2);
    6363        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ5.cs

    r15583 r16171  
    4242        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4343      }
    44       double[] res = new double[objectives];
     44      var res = new double[objectives];
    4545
    4646      //calculate g(Xm)
    4747      double g = 0;
    48       for (int i = objectives; i < r.Length; i++) {
    49         double d = r[i] - 0.5;
     48      for (var i = objectives; i < r.Length; i++) {
     49        var d = r[i] - 0.5;
    5050        g += d * d;
    5151      }
     
    5656
    5757      //calculating f0...fM-1
    58       for (int i = 0; i < objectives; i++) {
    59         double f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
    60         for (int j = 0; j < objectives - i - 1; j++) {
     58      for (var i = 0; i < objectives; i++) {
     59        var f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
     60        for (var j = 0; j < objectives - i - 1; j++) {
    6161          f *= Math.Cos(phi(r[j]) * Math.PI / 2);
    6262        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ6.cs

    r15583 r16171  
    4242        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4343      }
    44       double[] res = new double[objectives];
     44      var res = new double[objectives];
    4545
    4646      //calculate g(Xm)
    4747      double g = 0;
    48       for (int i = objectives; i < r.Length; i++) {
     48      for (var i = objectives; i < r.Length; i++) {
    4949        g += Math.Pow(r[i], 0.1);
    5050      }
     
    5555
    5656      //calculating f0...fM-1
    57       for (int i = 0; i < objectives; i++) {
    58         double f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
    59         for (int j = 0; j < objectives - i - 1; j++) {
     57      for (var i = 0; i < objectives; i++) {
     58        var f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
     59        for (var j = 0; j < objectives - i - 1; j++) {
    6060          f *= Math.Cos(phi(r[j]) * Math.PI / 2);
    6161        }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ7.cs

    r15583 r16171  
    4747        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4848      }
    49       double[] res = new double[objectives];
     49      var res = new double[objectives];
    5050
    5151      //calculate g(Xm)
    5252      double g = 0, length = length = r.Length - objectives + 1;
    53       for (int i = objectives; i < r.Length; i++) {
     53      for (var i = objectives; i < r.Length; i++) {
    5454        g += r[i];
    5555      }
     
    5858
    5959      //calculating f0...fM-2
    60       for (int i = 0; i < objectives - 1; i++) {
     60      for (var i = 0; i < objectives - 1; i++) {
    6161        res[i] = r[i];
    6262      }
    6363      //calculate fM-1
    6464      double h = objectives;
    65       for (int i = 0; i < objectives - 1; i++) {
     65      for (var i = 0; i < objectives - 1; i++) {
    6666        h -= res[i] / (1 + g) * (1 + Math.Sin(3 * Math.PI * res[i]));
    6767      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ8.cs

    r15583 r16171  
    3030  public class DTLZ8 : DTLZ, IConstrainedTestFunction {
    3131    public static double[] IllegalValue(int size, bool[] maximization) {
    32       double[] res = new double[size];
    33       for (int i = 0; i < size; i++) {
     32      var res = new double[size];
     33      for (var i = 0; i < size; i++) {
    3434        res[i] = maximization[i] ? Double.MinValue : Double.MaxValue;
    3535      }
     
    4949      double n = r.Length;
    5050      double M = objectives;
    51       double ratio = n / M;
    52       double[] res = new double[objectives];
    53       for (int j = 0; j < objectives; j++) {
     51      var ratio = n / M;
     52      var res = new double[objectives];
     53      for (var j = 0; j < objectives; j++) {
    5454        double sum = 0;
    55         for (int i = (int)(j * ratio); i < (j + 1) + ratio; i++) {
     55        for (var i = (int)(j * ratio); i < (j + 1) + ratio; i++) {
    5656          sum += r[i];
    5757        }
     
    5959        res[j] = sum;
    6060      }
    61       for (int j = 0; j < M - 1; j++) {
     61      for (var j = 0; j < M - 1; j++) {
    6262        if (res[objectives - 1] + 4 * res[j] - 1 < 0) return IllegalValue(objectives, GetMaximization(objectives));
    6363      }
    64       double min = Double.PositiveInfinity;
    65       for (int i = 0; i < res.Length - 1; i++) {
    66         for (int j = 0; j < i; j++) {
    67           double d = res[i] + res[j];
     64      var min = Double.PositiveInfinity;
     65      for (var i = 0; i < res.Length - 1; i++) {
     66        for (var j = 0; j < i; j++) {
     67          var d = res[i] + res[j];
    6868          if (min < d) min = d;
    6969        }
     
    7878      double n = r.Length;
    7979      double M = objectives;
    80       double ratio = n / M;
    81       double[] res = new double[objectives];
    82       double[] constraints = new double[objectives];
    83       for (int j = 0; j < objectives; j++) {
     80      var ratio = n / M;
     81      var res = new double[objectives];
     82      var constraints = new double[objectives];
     83      for (var j = 0; j < objectives; j++) {
    8484        double sum = 0;
    85         for (int i = (int)(j * ratio); i < (j + 1) + ratio; i++) {
     85        for (var i = (int)(j * ratio); i < (j + 1) + ratio; i++) {
    8686          sum += r[i];
    8787        }
     
    8989        res[j] = sum;
    9090      }
    91       for (int j = 0; j < M - 1; j++) {
    92         double d1 = res[objectives - 1] + 4 * res[j] - 1;
     91      for (var j = 0; j < M - 1; j++) {
     92        var d1 = res[objectives - 1] + 4 * res[j] - 1;
    9393        constraints[j] = d1 < 0 ? -d1 : 0;
    9494      }
    95       double min = Double.PositiveInfinity;
    96       for (int i = 0; i < res.Length - 1; i++) {
    97         for (int j = 0; j < i; j++) {
    98           double d2 = res[i] + res[j];
     95      var min = Double.PositiveInfinity;
     96      for (var i = 0; i < res.Length - 1; i++) {
     97        for (var j = 0; j < i; j++) {
     98          var d2 = res[i] + res[j];
    9999          if (min < d2) min = d2;
    100100        }
    101101      }
    102       double d = 2 * res[objectives - 1] + min - 1;
     102      var d = 2 * res[objectives - 1] + min - 1;
    103103      constraints[constraints.Length - 1] = d < 0 ? -d : 0;
    104104      return constraints;
Note: See TracChangeset for help on using the changeset viewer.