Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/MultiObjectiveTestfunctionTests/GenerationalDistanceTest.cs @ 14111

Last change on this file since 14111 was 14111, checked in by mkommend, 8 years ago

#1087: Change plugin and folder name from HeuristicLab.Problems.MultiObjectiveTestFunctions to HeuristicLab.Problems.Testfunctions.MultiObjective and adapted namespaces and projects accordingly.

File size: 4.2 KB
Line 
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;
22using HeuristicLab.Problems.TestFunctions.MultiObjective;
23using Microsoft.VisualStudio.TestTools.UnitTesting;
24
25namespace MultiObjectiveTestfunctionTests {
26  [TestClass]
27  public class GenerationalDistanceTest {
28
29    [TestMethod]
30    [ExpectedException(typeof(ArgumentException))]
31    [TestCategory("Problems.TestFunctions")]
32    [TestProperty("Time", "short")]
33    public void EmptyOptimalFrontTest() {
34
35      double[] point = new double[2];
36      point[0] = 0.5;
37      point[1] = 0.5;
38      double[][] front = { point };
39      double[][] referencefront = { };
40      GenerationalDistance.Calculate(front, referencefront, 1);
41    }
42
43    [TestMethod]
44    [ExpectedException(typeof(ArgumentException))]
45    [TestCategory("Problems.TestFunctions")]
46    [TestProperty("Time", "short")]
47    public void EmptyFrontTest() {
48
49      double[] point = new double[2];
50      point[0] = 0.5;
51      point[1] = 0.5;
52      double[][] front = { };
53      double[][] referencefront = { point };
54      GenerationalDistance.Calculate(front, referencefront, 1);
55    }
56
57    [TestMethod]
58    [TestCategory("Problems.TestFunctions")]
59    [TestProperty("Time", "short")]
60    public void SamePointTest() {
61
62      double[] point = new double[2];
63      point[0] = 0.5;
64      point[1] = 0.5;
65      double[][] front = { point };
66      double[] point1 = new double[2];
67      point1[0] = 0.5;
68      point1[1] = 0.5;
69      double[][] referencefront = { point1 };
70      double dist = GenerationalDistance.Calculate(front, referencefront, 1);
71      Assert.AreEqual(0, dist);
72    }
73
74    [TestMethod]
75    [TestCategory("Problems.TestFunctions")]
76    [TestProperty("Time", "short")]
77    public void SinglePointTest() {
78      double[] point = new double[2];
79      point[0] = 0;
80      point[1] = 0;
81      double[][] front = { point };
82      double[] point2 = new double[2];
83      point2[0] = 1;
84      point2[1] = 1;
85      double[][] referencefront = { point2 };
86      double dist = GenerationalDistance.Calculate(front, referencefront, 1);
87      Assert.AreEqual(Math.Sqrt(2), dist);
88    }
89
90    [TestMethod]
91    [TestCategory("Problems.TestFunctions")]
92    [TestProperty("Time", "short")]
93    public void DifferentSizesTest() {
94      double[] point = new double[2];
95      point[0] = 0;
96      point[1] = 0;
97      double[] point1 = new double[2];
98      point1[0] = 1;
99      point1[1] = 0.5;
100      double[][] front = { point, point1 };
101      double[] point2 = new double[2];
102      point2[0] = 1;
103      point2[1] = 0;
104      double[][] referencefront = { point2 };
105      double dist = GenerationalDistance.Calculate(front, referencefront, 1);
106      Assert.AreEqual(0.75, dist);
107    }
108
109    [TestMethod]
110    [TestCategory("Problems.TestFunctions")]
111    [TestProperty("Time", "short")]
112    public void QuadraticTest() {
113      double[] point = new double[2];
114      point[0] = 0;
115      point[1] = 0;
116      double[] point1 = new double[2];
117      point1[0] = 0;
118      point1[1] = 1;
119      double[][] front = { point, point1 };
120      double[] point2 = new double[2];
121      point2[0] = 1;
122      point2[1] = 0;
123      double[] point3 = new double[2];
124      point3[0] = 1;
125      point3[1] = 1;
126      double[][] referencefront = { point2, point3 };
127      double dist = GenerationalDistance.Calculate(front, referencefront, 1);
128      Assert.AreEqual(1, dist);
129    }
130
131
132
133  }
134
135
136}
Note: See TracBrowser for help on using the repository browser.