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("DTLZ4", " http://repository.ias.ac.in/81671/ [30.11.15]")]


16  [StorableClass]


17  public class DTLZ4 : MultiObjectiveTestFunction {


18 


19  public override DoubleMatrix Bounds {


20  get {


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


22  }


23  }


24 


25  public override bool[] Maximization {


26  get {


27  bool[] res = new bool[((ValueParameter<IntValue>)Parameters["SolutionSize"]).Value.Value];


28  for(int i =0; i < res.Length; i++) res[i] = false; //TODO: diligent initialzation


29  return res;


30  }


31  }


32 


33  public override int MaximumProblemSize {


34  get {


35  return int.MaxValue;


36  }


37  }


38 


39  public override int MaximumSolutionSize { //TODO ask Michael


40  get {


41  return ((ValueParameter<IntValue>)Parameters["ProblemSize"]).Value.Value;


42  }


43  }


44 


45  public override int MinimumProblemSize {


46  get {


47  return 2;


48  }


49  }


50 


51  public override int MinimumSolutionSize {


52  get {


53  return 2;


54  }


55  }


56 


57  public override int ActualSolutionSize {


58  get {


59  throw new NotImplementedException();


60  }


61 


62  set {


63  throw new NotImplementedException();


64  }


65  }


66 


67  [StorableConstructor]


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


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


70  public DTLZ4() : base() { }


71 


72  public override IDeepCloneable Clone(Cloner cloner) {


73  return new DTLZ4(this, cloner);


74  }


75 


76 


77 


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


79  return Evaluate(r, ((ValueParameter<IntValue>)Parameters["SolutionSize"]).Value.Value);


80  }


81 


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


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


84 


85  //calculate g(Xm)


86  double g = 0;


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


88  double d = r[i]  0.5;


89  g += d * d;


90  }


91 


92  //calculating f0...fM1


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


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


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


96  f *= Math.Cos(Math.Pow(r[j], 100) * Math.PI / 2);


97  }


98  res[i] = f;


99  }


100  return res;


101  }


102  }


103  }

