Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/09/16 12:44:23 (8 years ago)
Author:
bwerth
Message:

#1087 added Analyzers, reworked PFStore, added licence information, cleaned code

File:
1 edited

Legend:

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

    r13620 r13672  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2016 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
     21using System;
    222using HeuristicLab.Common;
    323using HeuristicLab.Core;
     
    1939    public DTLZ8() : base() { }
    2040
    21     public  double[] Evaluate2(RealVector r, int objectives) {
     41    public double[] Evaluate2(RealVector r, int objectives) {
    2242      if (r.Length < objectives) {
    2343        throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than or equal to ten times the dimensionality of the solution(SolutionSize) ");
     
    3656        if (c != 0) {
    3757          d *= 1.0 / c;
    38         } 
     58        }
    3959        res[i - 1] = d;
    4060      }
     
    5676
    5777    public override double[] Evaluate(RealVector r, int objectives) {
    58       if (r.Length < 10*objectives) throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than or equal to ten times the dimensionality of the solution(SolutionSize) ");
     78      if (r.Length < 10 * objectives) throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than ten times the number of objectives ");
    5979      double n = r.Length;
    6080      double M = objectives;
    6181      double ratio = n / M;
    6282      double[] res = new double[objectives];
    63       for(int j =0; j < objectives; j++) {
     83      for (int j = 0; j < objectives; j++) {
    6484        double sum = 0;
    65         for(int i = (int) (j*ratio); i < (j+1)+ratio; i++) {
    66           sum+=r[i];
     85        for (int i = (int)(j * ratio); i < (j + 1) + ratio; i++) {
     86          sum += r[i];
    6787        }
    68         sum /= (int) ratio;
     88        sum /= (int)ratio;
    6989        res[j] = sum;
    7090      }
    71       for(int j = 0; j < M - 1; j++) {
    72         if(res[objectives - 1]+4*res[j]-1<0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));
     91      for (int j = 0; j < M - 1; j++) {
     92        if (res[objectives - 1] + 4 * res[j] - 1 < 0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));
    7393      }
    7494      double min = Double.PositiveInfinity;
    75       for(int i =0; i < res.Length - 1; i++) {
    76         for(int j = 0;j< i; j++) {
     95      for (int i = 0; i < res.Length - 1; i++) {
     96        for (int j = 0; j < i; j++) {
    7797          double d = res[i] + res[j];
    7898          if (min < d) min = d;
     
    80100      }
    81101
    82       if (2*res[objectives-1]+min-1<0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));
     102      if (2 * res[objectives - 1] + min - 1 < 0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));
    83103      return res;
    84104    }
Note: See TracChangeset for help on using the changeset viewer.