Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/15/16 17:19:34 (8 years ago)
Author:
bwerth
Message:

#1087 regorganized testfunctions, added view for qualities

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/SchafferN1.cs

    r13515 r13620  
    1 using HeuristicLab.Common;
     1using System;
     2using System.Collections.Generic;
     3using HeuristicLab.Common;
    24using HeuristicLab.Core;
    35using HeuristicLab.Data;
     
    1012  public class SchafferN1 : MultiObjectiveTestFunction {
    1113
    12     public override DoubleMatrix Bounds {
    13       get {
    14         return new DoubleMatrix(new double[,] { { -1e5, 1e5 } });
    15       }
     14    public override double[,] Bounds(int objectives) {
     15      return new double[,] { { -1e5, 1e5 } };
    1616    }
    1717
    18     public override bool[] Maximization {
    19       get {
    20         return new bool[] { false, false };
    21       }
     18    public override bool[] Maximization(int objecitves) {
     19      return new bool[2];
    2220    }
    2321
    24     public override int MaximumProblemSize {
    25       get {
    26         return 1;
    27       }
     22    public override int MinimumSolutionLength {
     23      get { return 1; }
     24    }
     25    public override int MaximumSolutionLength {
     26      get { return 1; }
    2827    }
    2928
    30     public override int MaximumSolutionSize {
    31       get {
    32         return 2;
    33       }
     29
     30    public override int MinimumObjectives {
     31      get { return 2; }
    3432    }
    3533
    36     public override int MinimumProblemSize {
    37       get {
    38         return 1;
    39       }
     34    public override int MaximumObjectives {
     35      get { return 2; }
    4036    }
    4137
    42     public override int MinimumSolutionSize {
    43       get {
    44         return 2;
    45       }
     38
     39    public override double[] ReferencePoint(int objecitves) {
     40        return new double[] { 1e5, 1e5 };
    4641    }
    4742
    48     public override int ActualSolutionSize {
    49       get {
    50         return 2;
    51       }
    5243
    53       set {
    54       }
     44    public override IEnumerable<double[]> OptimalParetoFront(int objecitves) {
     45        return PFStore.get("Schaffer");
    5546    }
     47    public override double BestKnownHypervolume(int objecitves) {
     48        return new Hypervolume(ReferencePoint(objecitves), Maximization(2)).GetHypervolume(OptimalParetoFront(objecitves));
    5649
    57     public override RealVector[] OptimalParetoFront {
    58       get {
    59         return PFReader.getFromFile("SchafferN1");
    60       }
    61     }
    62     public override double BestKnownHypervolume {
    63       get {
    64         return new Hypervolume(base.ReferencePoint, Maximization).GetHypervolume(OptimalParetoFront);
    65       }
    6650    }
    6751
     
    6953    protected SchafferN1(bool deserializing) : base(deserializing) { }
    7054    protected SchafferN1(SchafferN1 original, Cloner cloner) : base(original, cloner) { }
    71     public SchafferN1() : base() { }
    72 
    7355    public override IDeepCloneable Clone(Cloner cloner) {
    7456      return new SchafferN1(this, cloner);
    7557    }
    7658
     59    public SchafferN1() : base() { }
    7760
    7861
    79     public override double[] Evaluate(RealVector r) {
     62
     63
     64
     65    public override double[] Evaluate(RealVector r, int objectives) {
     66      if (objectives != 2) throw new ArgumentException("The Schaffer N1 problem must always have 2 objectives");
    8067      if (r.Length != 1) return null;
    8168      double x = r[0];
     
    8875      f1 *= f1;
    8976
    90      return new double[] { f0, f1 };
     77      return new double[] { f0, f1 };
    9178    }
    9279  }
Note: See TracChangeset for help on using the changeset viewer.