1  #region License Information


2  /* HeuristicLab


3  * Copyright (C) 20022016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)


4  *


5  * This file is part of HeuristicLab.


6  *


7  * HeuristicLab is free software: you can redistribute it and/or modify


8  * it under the terms of the GNU General Public License as published by


9  * the Free Software Foundation, either version 3 of the License, or


10  * (at your option) any later version.


11  *


12  * HeuristicLab is distributed in the hope that it will be useful,


13  * but WITHOUT ANY WARRANTY; without even the implied warranty of


14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the


15  * GNU General Public License for more details.


16  *


17  * You should have received a copy of the GNU General Public License


18  * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.


19  */


20  #endregion


21  using System;


22  using HeuristicLab.Common;


23  using HeuristicLab.Core;


24  using HeuristicLab.Encodings.RealVectorEncoding;


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


26 


27  namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {


28  [Item("DTLZ8", "Testfunction as defined as DTLZ7 in http://repository.ias.ac.in/81671/ [30.11.15]. There has been a renumbering therefore the numbers do not match")]


29  [StorableClass]


30  public class DTLZ8 : DTLZ, IConstrainedTestFunction {


31 


32 


33  [StorableConstructor]


34  protected DTLZ8(bool deserializing) : base(deserializing) { }


35  protected DTLZ8(DTLZ8 original, Cloner cloner) : base(original, cloner) { }


36  public override IDeepCloneable Clone(Cloner cloner) {


37  return new DTLZ8(this, cloner);


38  }


39  public DTLZ8() : base() { }


40 


41  public override double[] Evaluate(RealVector r, int objectives) {


42  if (r.Length < 10 * objectives) throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than ten times the number of objectives ");


43  double n = r.Length;


44  double M = objectives;


45  double ratio = n / M;


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


47  for (int j = 0; j < objectives; j++) {


48  double sum = 0;


49  for (int i = (int)(j * ratio); i < (j + 1) + ratio; i++) {


50  sum += r[i];


51  }


52  sum /= (int)ratio;


53  res[j] = sum;


54  }


55  for (int j = 0; j < M  1; j++) {


56  if (res[objectives  1] + 4 * res[j]  1 < 0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));


57  }


58  double min = Double.PositiveInfinity;


59  for (int i = 0; i < res.Length  1; i++) {


60  for (int j = 0; j < i; j++) {


61  double d = res[i] + res[j];


62  if (min < d) min = d;


63  }


64  }


65 


66  if (2 * res[objectives  1] + min  1 < 0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));


67  return res;


68  }


69 


70  public double[] CheckConstraints(RealVector r, int objectives) {


71  if (r.Length < 10 * objectives) throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than ten times the number of objectives ");


72  double n = r.Length;


73  double M = objectives;


74  double ratio = n / M;


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


76  double[] constraints = new double[objectives];


77  for (int j = 0; j < objectives; j++) {


78  double sum = 0;


79  for (int i = (int)(j * ratio); i < (j + 1) + ratio; i++) {


80  sum += r[i];


81  }


82  sum /= (int)ratio;


83  res[j] = sum;


84  }


85  for (int j = 0; j < M  1; j++) {


86  double d1 = res[objectives  1] + 4 * res[j]  1;


87  constraints[j] = d1 < 0 ? d1 : 0;


88  }


89  double min = Double.PositiveInfinity;


90  for (int i = 0; i < res.Length  1; i++) {


91  for (int j = 0; j < i; j++) {


92  double d2 = res[i] + res[j];


93  if (min < d2) min = d2;


94  }


95  }


96  double d = 2 * res[objectives  1] + min  1;


97  constraints[constraints.Length  1] = d < 0 ? d : 0;


98  return constraints;


99  }


100  }


101  }

