[13673] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[16311] | 3 | * Copyright (C) 2002-2018 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
|
---|
| 21 | using System;
|
---|
| 22 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 23 |
|
---|
[14121] | 24 | namespace 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 | }
|
---|