[13673] | 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
|
---|
| 21 | using System;
|
---|
| 22 | using HeuristicLab.Problems.MultiObjectiveTestFunctions;
|
---|
| 23 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 24 |
|
---|
| 25 | namespace MultiObjectiveTestfunctionTests {
|
---|
| 26 | [TestClass]
|
---|
| 27 | public class SpacingTest {
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | [TestMethod]
|
---|
| 33 | [ExpectedException(typeof(ArgumentException))]
|
---|
[13729] | 34 | [TestCategory("Problems.TestFunctions")]
|
---|
| 35 | [TestProperty("Time", "short")]
|
---|
[13673] | 36 | public void EmptyFrontTest() {
|
---|
| 37 | double[][] front = { };
|
---|
| 38 |
|
---|
| 39 | Spacing.Calculate(front);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | [TestMethod]
|
---|
[13729] | 43 | [TestCategory("Problems.TestFunctions")]
|
---|
| 44 | [TestProperty("Time", "short")]
|
---|
[13673] | 45 | public void SamePointTest() {
|
---|
| 46 |
|
---|
| 47 | double[] point = new double[2];
|
---|
| 48 | point[0] = 0.5;
|
---|
| 49 | point[1] = 0.5;
|
---|
| 50 |
|
---|
| 51 | double[] point1 = new double[2];
|
---|
| 52 | point1[0] = 0.5;
|
---|
| 53 | point1[1] = 0.5;
|
---|
| 54 | double[][] front = { point, point1 };
|
---|
| 55 | double dist = Spacing.Calculate(front);
|
---|
| 56 | Assert.AreEqual(0, dist);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | [TestMethod]
|
---|
[13729] | 60 | [TestCategory("Problems.TestFunctions")]
|
---|
| 61 | [TestProperty("Time", "short")]
|
---|
[13673] | 62 | public void SinglePointTest() {
|
---|
| 63 | double[] point = new double[2];
|
---|
| 64 | point[0] = 0;
|
---|
| 65 | point[1] = 0;
|
---|
| 66 | double[][] front = { point };
|
---|
| 67 | double dist = Spacing.Calculate(front);
|
---|
| 68 | Assert.AreEqual(0, dist);
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | [TestMethod]
|
---|
[13729] | 72 | [TestCategory("Problems.TestFunctions")]
|
---|
| 73 | [TestProperty("Time", "short")]
|
---|
[13673] | 74 | public void QuadraticTest() {
|
---|
| 75 | double[] point = new double[2];
|
---|
| 76 | point[0] = 0;
|
---|
| 77 | point[1] = 0;
|
---|
| 78 | double[] point1 = new double[2];
|
---|
| 79 | point1[0] = 0;
|
---|
| 80 | point1[1] = 1;
|
---|
| 81 |
|
---|
| 82 | double[] point2 = new double[2];
|
---|
| 83 | point2[0] = 1;
|
---|
| 84 | point2[1] = 0;
|
---|
| 85 | double[] point3 = new double[2];
|
---|
| 86 | point3[0] = 1;
|
---|
| 87 | point3[1] = 1;
|
---|
| 88 | double[][] front = { point, point1, point2, point3 };
|
---|
| 89 | double dist = Spacing.Calculate(front);
|
---|
| 90 | Assert.AreEqual(0, dist);
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | [TestMethod]
|
---|
[13729] | 94 | [TestCategory("Problems.TestFunctions")]
|
---|
| 95 | [TestProperty("Time", "short")]
|
---|
[13673] | 96 | public void RectangularTest() {
|
---|
| 97 | double[] point = new double[2];
|
---|
| 98 | point[0] = 0;
|
---|
| 99 | point[1] = 0;
|
---|
| 100 | double[] point1 = new double[2];
|
---|
| 101 | point1[0] = 0;
|
---|
| 102 | point1[1] = 1;
|
---|
| 103 |
|
---|
| 104 | double[] point2 = new double[2];
|
---|
| 105 | point2[0] = 2;
|
---|
| 106 | point2[1] = 0;
|
---|
| 107 | double[] point3 = new double[2];
|
---|
| 108 | point3[0] = 2;
|
---|
| 109 | point3[1] = 1;
|
---|
| 110 | double[][] front = { point, point1, point2, point3 };
|
---|
| 111 | double dist = Spacing.Calculate(front);
|
---|
| 112 | Assert.AreEqual(0, dist);
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | /// <summary>
|
---|
| 116 | /// deltoid with 3 points of the 1-unit-square and the northeastern point at 4,4
|
---|
| 117 | /// which gives d=(1,1,1,5) for minimal distances. Mean of d is 2 and variance of d is 3
|
---|
| 118 | /// Spacing is defined as the standarddeviation of d
|
---|
| 119 | /// </summary>
|
---|
| 120 | [TestMethod]
|
---|
[13729] | 121 | [TestCategory("Problems.TestFunctions")]
|
---|
| 122 | [TestProperty("Time", "short")]
|
---|
[13673] | 123 | public void DeltoidTest() {
|
---|
| 124 | double[] point = new double[2];
|
---|
| 125 | point[0] = 0;
|
---|
| 126 | point[1] = 0;
|
---|
| 127 | double[] point1 = new double[2];
|
---|
| 128 | point1[0] = 0;
|
---|
| 129 | point1[1] = 1;
|
---|
| 130 |
|
---|
| 131 | double[] point2 = new double[2];
|
---|
| 132 | point2[0] = 1;
|
---|
| 133 | point2[1] = 0;
|
---|
| 134 | double[] point3 = new double[2];
|
---|
| 135 | point3[0] = 4;
|
---|
| 136 | point3[1] = 4;
|
---|
| 137 | double[][] front = { point, point1, point2, point3 };
|
---|
| 138 | double dist = Spacing.Calculate(front);
|
---|
| 139 | Assert.AreEqual(Math.Sqrt(3), dist);
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | }
|
---|