1  using System;


2  using System.Collections.Generic;


3  using System.Linq;


4  using System.Text;


5  using System.Threading.Tasks;


6  using HeuristicLab.Common;


7  using HeuristicLab.Core;


8  using HeuristicLab.Data;


9  using HeuristicLab.Encodings.RealVectorEncoding;


10  using HeuristicLab.Parameters;


11  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;


12  using HeuristicLab.Problems.MultiObjectiveTestFunction;


13 


14  namespace HeuristicLab.Problems.TestFunctions {


15  [Item("DTLZ5", " http://repository.ias.ac.in/81671/ [30.11.15]")]


16  [StorableClass]


17  public class DTLZ5 : MultiObjectiveTestFunction {


18 


19  private int actualSolutionSize = 2;


20  public override int ActualSolutionSize {


21  get {


22  return actualSolutionSize;


23  }


24 


25  set {


26  actualSolutionSize = value;


27  }


28  }


29 


30  public override DoubleMatrix Bounds {


31  get {


32  return new DoubleMatrix(new double[,] { { 0, 1 } });


33  }


34  }


35 


36  public override bool[] Maximization {


37  get {


38  return new bool[actualSolutionSize];


39  }


40  }


41 


42  public override int MaximumProblemSize {


43  get {


44  return int.MaxValue;


45  }


46  }


47 


48  public override int MaximumSolutionSize {


49  get {


50 


51  return int.MaxValue;


52  }


53  }


54 


55  public override int MinimumProblemSize {


56  get {


57  return Math.Max(2, ActualSolutionSize+1);


58  }


59  }


60 


61  public override int MinimumSolutionSize {


62  get {


63  return 2;


64  }


65  }


66 


67  [StorableConstructor]


68  protected DTLZ5(bool deserializing) : base(deserializing) { }


69  protected DTLZ5(DTLZ5 original, Cloner cloner) : base(original, cloner) { }


70  public DTLZ5() : base() { }


71 


72  public override IDeepCloneable Clone(Cloner cloner) {


73  return new DTLZ5(this, cloner);


74  }


75 


76 


77 


78  public override double[] Evaluate(RealVector r) {


79  return Evaluate(r, ActualSolutionSize);


80  }


81 


82  private double[] Evaluate(RealVector r, int objectives) {


83  if (r.Length < objectives) {


84  throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than the dimensionality of the solution(SolutionSize) ");


85  }


86  double[] res = new double[objectives];


87 


88  //calculate g(Xm)


89  double g = 0;


90  for (int i = objectives; i < r.Length; i++) {


91  g += Math.Pow(r[i], 0.1);


92  }


93 


94  //phi definition


95  Func<double, double> phi;


96  phi = (double x) => { return Math.PI / (4 * 1 + g) * (1 + 2 * g * x); };


97 


98  //calculating f0...fM1


99  for (int i = 0; i < objectives; i++) {


100  double f = i == 0 ? 1 : (Math.Sin(phi(r[objectives  i  1]) * Math.PI / 2)) * (1 + g);


101  for (int j = 0; j < objectives  i  1; j++) {


102  f *= Math.Cos(phi(r[j]) * Math.PI / 2);


103  }


104  res[i] = f;


105  }


106  return res;


107  }


108  }


109  }

