Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Tests/HeuristicLab.Problems.TestFunctions.MultiObjective-3.3/InvertedGenerationalDistanceTest.cs @ 17507

Last change on this file since 17507 was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

File size: 4.4 KB
RevLine 
[13673]1#region License Information
2/* HeuristicLab
[17180]3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[13673]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;
22using Microsoft.VisualStudio.TestTools.UnitTesting;
23
[14121]24namespace HeuristicLab.Problems.TestFunctions.MultiObjective.Tests {
[13673]25  [TestClass]
26  public class InvertedGenerationalDistanceTest {
27
28    [TestMethod]
29    [ExpectedException(typeof(ArgumentException))]
[14121]30    [TestCategory("Problems.TestFunctions.MultiObjective")]
[13729]31    [TestProperty("Time", "short")]
[14121]32    public void InvertedGenerationalDistanceTestEmptyOptimalFront() {
[13673]33
34      double[] point = new double[2];
35      point[0] = 0.5;
36      point[1] = 0.5;
37      double[][] front = { point };
38      double[][] referencefront = { };
39      InvertedGenerationalDistance.Calculate(front, referencefront, 1);
40    }
41
42    [TestMethod]
43    [ExpectedException(typeof(ArgumentException))]
[14121]44    [TestCategory("Problems.TestFunctions.MultiObjective")]
[13729]45    [TestProperty("Time", "short")]
[14121]46    public void InvertedGenerationalDistanceTestEmptyFront() {
[13673]47
48      double[] point = new double[2];
49      point[0] = 0.5;
50      point[1] = 0.5;
51      double[][] front = { };
52      double[][] referencefront = { point };
53      InvertedGenerationalDistance.Calculate(front, referencefront, 1);
54    }
55
56    [TestMethod]
[14121]57    [TestCategory("Problems.TestFunctions.MultiObjective")]
[13729]58    [TestProperty("Time", "short")]
[14121]59    public void InvertedGenerationalDistanceTestSamePoint() {
[13673]60      double[] point = new double[2];
61      point[0] = 0.5;
62      point[1] = 0.5;
63      double[][] front = { point };
64      double[] point1 = new double[2];
65      point1[0] = 0.5;
66      point1[1] = 0.5;
67      double[][] referencefront = { point1 };
68      double dist = GenerationalDistance.Calculate(front, referencefront, 1);
69      Assert.AreEqual(0, dist);
70    }
71
72    [TestMethod]
[14121]73    [TestCategory("Problems.TestFunctions.MultiObjective")]
[13729]74    [TestProperty("Time", "short")]
[14121]75    public void InvertedGenerationalDistanceTestSinglePoint() {
[13673]76      double[] point = new double[2];
77      point[0] = 0;
78      point[1] = 0;
79      double[][] front = { point };
80      double[] point2 = new double[2];
81      point2[0] = 1;
82      point2[1] = 1;
83      double[][] referencefront = { point2 };
84      double dist = InvertedGenerationalDistance.Calculate(front, referencefront, 1);
85      Assert.AreEqual(Math.Sqrt(2), dist);
86    }
87
88    [TestMethod]
[14121]89    [TestCategory("Problems.TestFunctions.MultiObjective")]
[13729]90    [TestProperty("Time", "short")]
[14121]91    public void InvertedGenerationalDistanceTestDifferentSizes() {
[13673]92      double[] point = new double[2];
93      point[0] = 0;
94      point[1] = 0;
95      double[] point1 = new double[2];
96      point1[0] = 1;
97      point1[1] = 0.5;
98      double[][] front = { point, point1 };
99      double[] point2 = new double[2];
100      point2[0] = 1;
101      point2[1] = 0;
102      double[][] referencefront = { point2 };
103      double dist = InvertedGenerationalDistance.Calculate(front, referencefront, 1);
104      Assert.AreEqual(0.5, dist);
105    }
106
107    [TestMethod]
[14121]108    [TestCategory("Problems.TestFunctions.MultiObjective")]
[13729]109    [TestProperty("Time", "short")]
[14121]110    public void InvertedGenerationalDistanceTestQuadratic() {
[13673]111      double[] point = new double[2];
112      point[0] = 0;
113      point[1] = 0;
114      double[] point1 = new double[2];
115      point1[0] = 0;
116      point1[1] = 1;
117      double[][] front = { point, point1 };
118      double[] point2 = new double[2];
119      point2[0] = 1;
120      point2[1] = 0;
121      double[] point3 = new double[2];
122      point3[0] = 1;
123      point3[1] = 1;
124      double[][] referencefront = { point2, point3 };
125      double dist = InvertedGenerationalDistance.Calculate(front, referencefront, 1);
126      Assert.AreEqual(1, dist);
127    }
128  }
129
130
131}
Note: See TracBrowser for help on using the repository browser.