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