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

File:
1 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 };
Note: See TracChangeset for help on using the changeset viewer.