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/Misc
Files:
6 edited

Legend:

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

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
     27using HeuristicLab.Optimization;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    4345
    4446    protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
    45       List<double[]> res = new List<double[]>();
    46       for (int i = 0; i <= 500; i++) {
    47         RealVector r = new RealVector(2);
     47      var res = new List<double[]>();
     48      for (var i = 0; i <= 500; i++) {
     49        var r = new RealVector(2);
    4850        r[0] = 2 / 500.0 * i;
    4951        r[1] = 2 / 500.0 * i;
     
    5456
    5557    protected override double GetBestKnownHypervolume(int objectives) {
    56       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     58      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    5759    }
    5860
     
    6870    public override double[] Evaluate(RealVector r, int objectives) {
    6971      if (objectives != 2) throw new ArgumentException("The CIGTAB problem must always have 2 objectives");
    70       double x = r[0];
     72      var x = r[0];
    7173      double a = 1000;
    72       double sum = x * x;
    73       for (int i = 1; i < r.Length - 1; i++) {
     74      var sum = x * x;
     75      for (var i = 1; i < r.Length - 1; i++) {
    7476        sum += a * r[i] * r[i];
    7577      }
     
    7779
    7880      //objective1
    79       double f0 = 1 / (a * a * r.Length) * sum;
     81      var f0 = 1 / (a * a * r.Length) * sum;
    8082
    8183      x = x - 2;
    8284      sum = x * x;
    83       for (int i = 1; i < r.Length - 1; i++) {
     85      for (var i = 1; i < r.Length - 1; i++) {
    8486        sum += a * (r[i] - 2) * (r[i] - 2);
    8587      }
     
    8789      sum += a * a * (r[r.Length - 1] - 2) * (r[r.Length - 1] - 2);
    8890      //objective0
    89       double f1 = 1 / (a * a * r.Length) * sum;
     91      var f1 = 1 / (a * a * r.Length) * sum;
    9092
    9193      return new double[] { f0, f1 };
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/ELLI1.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
     27using HeuristicLab.Optimization;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    4345
    4446    protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
    45       List<double[]> res = new List<double[]>();
    46       for (int i = 0; i <= 500; i++) {
    47         RealVector r = new RealVector(2);
     47      var res = new List<double[]>();
     48      for (var i = 0; i <= 500; i++) {
     49        var r = new RealVector(2);
    4850        r[0] = 2 / 500.0 * i;
    4951        r[1] = 2 / 500.0 * i;
     
    5456
    5557    protected override double GetBestKnownHypervolume(int objectives) {
    56       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     58      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    5759    }
    5860
     
    6971      if (objectives != 2) throw new ArgumentException("The ELLI problem must always have 2 objectives");
    7072      double a = 1000;
    71       double sum = 0.0;
    72       for (int i = 0; i < r.Length; i++) {
     73      var sum = 0.0;
     74      for (var i = 0; i < r.Length; i++) {
    7375        sum += Math.Pow(a, 2 * i / (r.Length - 1)) * r[i] * r[i];
    7476      }
    7577
    7678      //objective1
    77       double f0 = 1 / (a * a * r.Length) * sum;
     79      var f0 = 1 / (a * a * r.Length) * sum;
    7880
    7981      sum = 0.0;
    80       for (int i = 0; i < r.Length; i++) {
     82      for (var i = 0; i < r.Length; i++) {
    8183        sum += Math.Pow(a, 2 * i / (r.Length - 1)) * (r[i] - 2) * (r[i] - 2);
    8284      }
    8385      //objective0
    84       double f1 = 1 / (a * a * r.Length) * sum;
     86      var f1 = 1 / (a * a * r.Length) * sum;
    8587
    8688      return new double[] { f0, f1 };
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Fonseca.cs

    r15583 r16171  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Encodings.RealVectorEncoding;
     28using HeuristicLab.Optimization;
    2729using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2830
     
    4446
    4547    protected override double GetBestKnownHypervolume(int objectives) {
    46       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     48      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    4749    }
    4850
     
    6567
    6668      //objective1
    67       for (int i = 0; i < r.Length; i++) {
    68         double d = r[i] - aux;
     69      for (var i = 0; i < r.Length; i++) {
     70        var d = r[i] - aux;
    6971        f0 += d * d;
    7072      }
     
    7274
    7375      //objective2
    74       double f1 = 0.0;
    75       for (int i = 0; i < r.Length; i++) {
    76         double d = r[i] + aux;
     76      var f1 = 0.0;
     77      for (var i = 0; i < r.Length; i++) {
     78        var d = r[i] + aux;
    7779        f1 += d * d;
    7880      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Kursawe.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
     27using HeuristicLab.Optimization;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    4345
    4446    protected override double GetBestKnownHypervolume(int objectives) {
    45       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     47      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    4648    }
    4749
     
    6567      if (objectives != 2) throw new ArgumentException("The Kursawe problem must always have 2 objectives");
    6668      //objective 1
    67       double f0 = 0.0;
    68       for (int i = 0; i < r.Length - 1; i++) {
     69      var f0 = 0.0;
     70      for (var i = 0; i < r.Length - 1; i++) {
    6971        f0 += -10 * Math.Exp(-0.2 * Math.Sqrt(r[i] * r[i] + r[i + 1] * r[i + 1]));
    7072      }
    7173      //objective2
    72       double f1 = 0.0;
    73       for (int i = 0; i < r.Length; i++) {
     74      var f1 = 0.0;
     75      for (var i = 0; i < r.Length; i++) {
    7476        f1 += Math.Pow(Math.Abs(r[i]), 0.8) + 5 * Math.Sin(Math.Pow(r[i], 3));
    7577      }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/SchafferN1.cs

    r15583 r16171  
    2121using System;
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
     27using HeuristicLab.Optimization;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    4850
    4951    protected override double GetBestKnownHypervolume(int objectives) {
    50       return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
     52      return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives));
    5153    }
    5254
     
    6365      if (objectives != 2) throw new ArgumentException("The Schaffer N1 problem must always have 2 objectives");
    6466      if (r.Length != 1) return null;
    65       double x = r[0];
     67      var x = r[0];
    6668
    6769      //objective1
    68       double f0 = x * x;
     70      var f0 = x * x;
    6971
    7072      //objective0
    71       double f1 = x - 2;
     73      var f1 = x - 2;
    7274      f1 *= f1;
    7375
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/SchafferN2.cs

    r15583 r16171  
    5959    public override double[] Evaluate(RealVector r, int objectives) {
    6060      if (objectives != 2) throw new ArgumentException("The Schaffer N1 problem must always have 2 objectives");
    61       double x = r[0];
     61      var x = r[0];
    6262
    6363      //objective1
     
    6969
    7070      //objective0
    71       double f1 = x - 5;
     71      var f1 = x - 5;
    7272      f1 *= f1;
    7373
Note: See TracChangeset for help on using the changeset viewer.