Changeset 17262
- Timestamp:
- 09/17/19 17:28:33 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Tests
- Files:
-
- 1 added
- 1 deleted
- 1 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/Multi-objective/CrowdingTest.cs
r17261 r17262 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 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 Microsoft.VisualStudio.TestTools.UnitTesting; 1 //#region License Information 2 ///* HeuristicLab 3 // * Copyright (C) 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 Microsoft.VisualStudio.TestTools.UnitTesting; 23 //using HeuristicLab.Optimization; 23 24 24 namespace HeuristicLab.Problems.TestFunctions.MultiObjective.Tests {25 [TestClass]26 public class CrowdingTest {25 //namespace HeuristicLab.Analysis.Tests { 26 // [TestClass] 27 // public class CrowdingTest { 27 28 28 [TestMethod]29 [ExpectedException(typeof(ArgumentException))]30 [TestCategory("Problems.TestFunctions.MultiObjective")]31 [TestProperty("Time", "short")]32 public void CrowdingTestEmptyFront() {33 double[][] front = { };29 // [TestMethod] 30 // [ExpectedException(typeof(ArgumentException))] 31 // [TestCategory("Analysis.MultiObjective")] 32 // [TestProperty("Time", "short")] 33 // public void CrowdingTestEmptyFront() { 34 // double[][] front = { }; 34 35 35 Crowding.Calculate(front, null);36 }36 // CrowdingCalculator.CalculateCrowding(front); 37 // } 37 38 38 [TestMethod]39 [TestCategory("Problems.TestFunctions.MultiObjective")]40 [TestProperty("Time", "short")]41 public void CrowdingTestSamePoint() {39 // [TestMethod] 40 // [TestCategory("Analysis.MultiObjective")] 41 // [TestProperty("Time", "short")] 42 // public void CrowdingTestSamePoint() { 42 43 43 double[] point = new double[2];44 point[0] = 0.5;45 point[1] = 0.5;44 // double[] point = new double[2]; 45 // point[0] = 0.5; 46 // point[1] = 0.5; 46 47 47 double[] point1 = new double[2];48 point1[0] = 0.5;49 point1[1] = 0.5;50 double[][] front = { point, point1 };51 double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } });52 Assert.AreEqual(double.PositiveInfinity, dist);53 }48 // double[] point1 = new double[2]; 49 // point1[0] = 0.5; 50 // point1[1] = 0.5; 51 // double[][] front = { point, point1 }; 52 // double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } }); 53 // Assert.AreEqual(double.PositiveInfinity, dist); 54 // } 54 55 55 [TestMethod]56 [TestCategory("Problems.TestFunctions.MultiObjective")]57 [TestProperty("Time", "short")]58 public void CrowdingTestSinglePoint() {59 double[] point = new double[2];60 point[0] = 0;61 point[1] = 0;62 double[][] front = { point };63 double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } });64 Assert.AreEqual(double.PositiveInfinity, dist);65 }56 // [TestMethod] 57 // [TestCategory("Analysis.MultiObjective")] 58 // [TestProperty("Time", "short")] 59 // public void CrowdingTestSinglePoint() { 60 // double[] point = new double[2]; 61 // point[0] = 0; 62 // point[1] = 0; 63 // double[][] front = { point }; 64 // double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } }); 65 // Assert.AreEqual(double.PositiveInfinity, dist); 66 // } 66 67 67 [TestMethod]68 [TestCategory("Problems.TestFunctions.MultiObjective")]69 [TestProperty("Time", "short")]70 public void CrowdingTestDiagonal() {71 double[] point = new double[2];72 point[0] = 0;73 point[1] = 0;74 double[] point1 = new double[2];75 point1[0] = 0.5;76 point1[1] = 0.5;68 // [TestMethod] 69 // [TestCategory("Analysis.MultiObjective")] 70 // [TestProperty("Time", "short")] 71 // public void CrowdingTestDiagonal() { 72 // double[] point = new double[2]; 73 // point[0] = 0; 74 // point[1] = 0; 75 // double[] point1 = new double[2]; 76 // point1[0] = 0.5; 77 // point1[1] = 0.5; 77 78 78 double[] point2 = new double[2];79 point2[0] = 1;80 point2[1] = 1;81 double[][] front = { point, point1, point2 };82 double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } });83 Assert.AreEqual(2, dist);84 }79 // double[] point2 = new double[2]; 80 // point2[0] = 1; 81 // point2[1] = 1; 82 // double[][] front = { point, point1, point2 }; 83 // double dist = Crowding.Calculate(front, new double[,] { { 0, 1 }, { 0, 1 } }); 84 // Assert.AreEqual(2, dist); 85 // } 85 86 86 [TestMethod]87 [TestCategory("Problems.TestFunctions.MultiObjective")]88 [TestProperty("Time", "short")]89 public void CrowdingTestDiamond() {90 double[] point = new double[2];91 point[0] = 0;92 point[1] = 0;93 double[] point1 = new double[2];94 point1[0] = 1;95 point1[1] = 1.5;87 // [TestMethod] 88 // [TestCategory("Analysis.MultiObjective")] 89 // [TestProperty("Time", "short")] 90 // public void CrowdingTestDiamond() { 91 // double[] point = new double[2]; 92 // point[0] = 0; 93 // point[1] = 0; 94 // double[] point1 = new double[2]; 95 // point1[0] = 1; 96 // point1[1] = 1.5; 96 97 97 double[] point2 = new double[2];98 point2[0] = 3;99 point2[1] = 0.5;100 double[] point3 = new double[2];101 point3[0] = 4;102 point3[1] = 2;103 double[][] front = { point, point1, point2, point3 };104 double dist = Crowding.Calculate(front, new double[,] { { 0, 4 }, { 0, 2 } });105 Assert.AreEqual(1.5, dist);106 }98 // double[] point2 = new double[2]; 99 // point2[0] = 3; 100 // point2[1] = 0.5; 101 // double[] point3 = new double[2]; 102 // point3[0] = 4; 103 // point3[1] = 2; 104 // double[][] front = { point, point1, point2, point3 }; 105 // double dist = Crowding.Calculate(front, new double[,] { { 0, 4 }, { 0, 2 } }); 106 // Assert.AreEqual(1.5, dist); 107 // } 107 108 108 /// <summary>109 /// deltoid with 4 points of the 1-unit-square and the northeastern point at 4,4110 ///111 /// </summary>112 [TestMethod]113 [TestCategory("Problems.TestFunctions.MultiObjective")]114 [TestProperty("Time", "short")]115 public void CrowdingTestDeltoid() {116 double[] point = new double[2];117 point[0] = 0;118 point[1] = 0;119 double[] point1 = new double[2];120 point1[0] = 0.00000001; //points should not be exactly equal because sorting behaviour could change result121 point1[1] = 1.00000001;109 // /// <summary> 110 // /// deltoid with 4 points of the 1-unit-square and the northeastern point at 4,4 111 // /// 112 // /// </summary> 113 // [TestMethod] 114 // [TestCategory("Analysis.MultiObjective")] 115 // [TestProperty("Time", "short")] 116 // public void CrowdingTestDeltoid() { 117 // double[] point = new double[2]; 118 // point[0] = 0; 119 // point[1] = 0; 120 // double[] point1 = new double[2]; 121 // point1[0] = 0.00000001; //points should not be exactly equal because sorting behavior could change result 122 // point1[1] = 1.00000001; 122 123 123 double[] point2 = new double[2];124 point2[0] = 1;125 point2[1] = 0;126 double[] point3 = new double[2];127 point3[0] = 4;128 point3[1] = 4;124 // double[] point2 = new double[2]; 125 // point2[0] = 1; 126 // point2[1] = 0; 127 // double[] point3 = new double[2]; 128 // point3[0] = 4; 129 // point3[1] = 4; 129 130 130 131 131 double[][] front = { point, point1, point2, point3, };132 double dist = Crowding.Calculate(front, new double[,] { { 0, 4 }, { 0, 4 } });133 Assert.AreEqual(1.25, dist);134 }132 // double[][] front = { point, point1, point2, point3, }; 133 // double dist = Crowding.Calculate(front, new double[,] { { 0, 4 }, { 0, 4 } }); 134 // Assert.AreEqual(1.25, dist); 135 // } 135 136 136 137 137 }138 // } 138 139 139 140 140 }141 //} -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/Multi-objective/FastHyperVolumeTests.cs
r17261 r17262 20 20 #endregion 21 21 using System; 22 using HeuristicLab.Optimization; 22 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 24 24 namespace HeuristicLab. Problems.TestFunctions.MultiObjective.Tests {25 namespace HeuristicLab.Analysis.MultiObjective.Tests { 25 26 [TestClass] 26 27 public class FastHypervolumeTest { … … 38 39 /// </summary> 39 40 [TestMethod] 40 [TestCategory(" Problems.TestFunctions.MultiObjective")]41 [TestCategory("Analysis.MultiObjective")] 41 42 [TestProperty("Time", "short")] 42 43 public void FastHypervolumeTestSinglePoint() { … … 44 45 double[][] front = { point }; 45 46 double[] referencePoint = new double[] { 1, 1, 1 }; 46 double hv = Hypervolume .Calculate(front, referencePoint, new bool[3]);47 double hv = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, new bool[3]); 47 48 Assert.AreEqual(0.125, hv); 48 49 } … … 56 57 /// +-----+ 57 58 /// 58 /// box between(0,0) and(1,1) with singular point pareto front at a random Location59 /// box between(0,0) and(1,1) with singular point Pareto front at a random Location 59 60 /// Sum of the Hypervolume to each of the corners should be 1; 60 61 /// 61 62 /// </summary> 62 63 [TestMethod] 63 [TestCategory(" Problems.TestFunctions.MultiObjective")]64 [TestCategory("Analysis.MultiObjective")] 64 65 [TestProperty("Time", "short")] 65 66 public void FastHypervolumeTestRandomSinglePoint() { … … 79 80 referencePoint[1] = 1; 80 81 referencePoint[2] = 1; 81 double hv = Hypervolume .Calculate(front, referencePoint, new bool[3]);82 double hv = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, new bool[3]); 82 83 double hv2 = 1; 83 84 foreach (double d in point) { … … 95 96 /// +-----x 96 97 /// 97 /// box between(0,0,0) and(1,1,1) with three point ( pareto) front at (1,0,0), (0.5,0.5,0) and (0,1,0)98 /// box between(0,0,0) and(1,1,1) with three point (Pareto) front at (1,0,0), (0.5,0.5,0) and (0,1,0) 98 99 /// Hypervolume should be 0.25 99 100 /// </summary> 100 101 [TestMethod] 101 [TestCategory(" Problems.TestFunctions.MultiObjective")]102 [TestCategory("Analysis.MultiObjective")] 102 103 [TestProperty("Time", "short")] 103 104 public void FastHypervolumeTestDiagonalPoint() { … … 109 110 110 111 double[] referencePoint = new double[] { 1, 1, 1 }; 111 double hv = Hypervolume .Calculate(front, referencePoint, new bool[3]);112 double hv = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, new bool[3]); 112 113 Assert.AreEqual(0.5, hv); 113 114 } -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/Multi-objective/GenerationalDistanceTest.cs
r17261 r17262 20 20 #endregion 21 21 using System; 22 using HeuristicLab.Analysis; 22 23 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 24 24 namespace HeuristicLab. Problems.TestFunctions.MultiObjective.Tests {25 namespace HeuristicLab.Analysis.MultiObjective.Tests { 25 26 [TestClass] 26 27 public class GenerationalDistanceTest { … … 28 29 [TestMethod] 29 30 [ExpectedException(typeof(ArgumentException))] 30 [TestCategory(" Problems.TestFunctions.MultiObjective")]31 [TestCategory("Analysis.MultiObjective")] 31 32 [TestProperty("Time", "short")] 32 33 public void GenerationalDistanceTestEmptyOptimalFront() { … … 37 38 double[][] front = { point }; 38 39 double[][] referencefront = { }; 39 GenerationalDistance .Calculate(front, referencefront, 1);40 GenerationalDistanceAnalyzer.CalculateGenerationalDistance(front, referencefront, 1); 40 41 } 41 42 42 43 [TestMethod] 43 44 [ExpectedException(typeof(ArgumentException))] 44 [TestCategory(" Problems.TestFunctions.MultiObjective")]45 [TestCategory("Analysis.MultiObjective")] 45 46 [TestProperty("Time", "short")] 46 47 public void GenerationalDistanceTestEmptyFront() { … … 51 52 double[][] front = { }; 52 53 double[][] referencefront = { point }; 53 GenerationalDistance .Calculate(front, referencefront, 1);54 GenerationalDistanceAnalyzer.CalculateGenerationalDistance(front, referencefront, 1); 54 55 } 55 56 56 57 [TestMethod] 57 [TestCategory(" Problems.TestFunctions.MultiObjective")]58 [TestCategory("Analysis.MultiObjective")] 58 59 [TestProperty("Time", "short")] 59 60 public void GenerationalDistanceTestSamePoint() { … … 67 68 point1[1] = 0.5; 68 69 double[][] referencefront = { point1 }; 69 double dist = GenerationalDistance .Calculate(front, referencefront, 1);70 double dist = GenerationalDistanceAnalyzer.CalculateGenerationalDistance(front, referencefront, 1); 70 71 Assert.AreEqual(0, dist); 71 72 } 72 73 73 74 [TestMethod] 74 [TestCategory(" Problems.TestFunctions.MultiObjective")]75 [TestCategory("Analysis.MultiObjective")] 75 76 [TestProperty("Time", "short")] 76 77 public void GenerationalDistanceTestSinglePoint() { … … 83 84 point2[1] = 1; 84 85 double[][] referencefront = { point2 }; 85 double dist = GenerationalDistance .Calculate(front, referencefront, 1);86 double dist = GenerationalDistanceAnalyzer.CalculateGenerationalDistance(front, referencefront, 1); 86 87 Assert.AreEqual(Math.Sqrt(2), dist); 87 88 } 88 89 89 90 [TestMethod] 90 [TestCategory(" Problems.TestFunctions.MultiObjective")]91 [TestCategory("Analysis.MultiObjective")] 91 92 [TestProperty("Time", "short")] 92 93 public void GenerationalDistanceTestDifferentSizes() { … … 102 103 point2[1] = 0; 103 104 double[][] referencefront = { point2 }; 104 double dist = GenerationalDistance .Calculate(front, referencefront, 1);105 double dist = GenerationalDistanceAnalyzer.CalculateGenerationalDistance(front, referencefront, 1); 105 106 Assert.AreEqual(0.75, dist); 106 107 } 107 108 108 109 [TestMethod] 109 [TestCategory(" Problems.TestFunctions.MultiObjective")]110 [TestCategory("Analysis.MultiObjective")] 110 111 [TestProperty("Time", "short")] 111 112 public void GenerationalDistanceTestQuadratic() { … … 124 125 point3[1] = 1; 125 126 double[][] referencefront = { point2, point3 }; 126 double dist = GenerationalDistance .Calculate(front, referencefront, 1);127 double dist = GenerationalDistanceAnalyzer.CalculateGenerationalDistance(front, referencefront, 1); 127 128 Assert.AreEqual(1, dist); 128 129 } -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/Multi-objective/HyperVolumeTests.cs
r17261 r17262 20 20 #endregion 21 21 using System; 22 using System.Linq; 23 using HeuristicLab.Optimization; 22 24 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 25 24 namespace HeuristicLab. Problems.TestFunctions.MultiObjective.Tests {26 namespace HeuristicLab.Analysis.MultiObjective.Tests { 25 27 [TestClass] 26 28 public class HypervolumeTest { … … 34 36 /// +-----+ 35 37 /// 36 /// box between(0,0) and(1,1) with singular point pareto front at(0.5,0.5)38 /// box between(0,0) and(1,1) with singular point Pareto front at(0.5,0.5) 37 39 /// Hypervolume to each of the corners should be 0.25; 38 40 /// 39 41 /// </summary> 40 42 [TestMethod] 41 [TestCategory(" Problems.TestFunctions.MultiObjective")]43 [TestCategory("Analysis.MultiObjective")] 42 44 [TestProperty("Time", "short")] 43 45 public void HypervolumeTestSinglePoint() { … … 56 58 referencePoint[0] = 1; 57 59 referencePoint[1] = 1; 58 double ne = Hypervolume .Calculate(front, referencePoint, maximization);60 double ne = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 59 61 Assert.AreEqual(0.25, ne); 60 62 … … 63 65 referencePoint[0] = 0; 64 66 referencePoint[1] = 1; 65 double nw = Hypervolume .Calculate(front, referencePoint, maximization);67 double nw = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 66 68 Assert.AreEqual(0.25, nw); 67 69 … … 70 72 referencePoint[0] = 0; 71 73 referencePoint[1] = 0; 72 double sw = Hypervolume .Calculate(front, referencePoint, maximization);74 double sw = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 73 75 Assert.AreEqual(0.25, sw); 74 76 … … 77 79 referencePoint[0] = 1; 78 80 referencePoint[1] = 0; 79 double se = Hypervolume .Calculate(front, referencePoint, maximization);81 double se = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 80 82 Assert.AreEqual(0.25, se); 81 83 … … 91 93 /// +-----+ 92 94 /// 93 /// box between(0,0) and(1,1) with singular point pareto front at a random Location95 /// box between(0,0) and(1,1) with singular point Pareto front at a random Location 94 96 /// Sum of the Hypervolume to each of the corners should be 1; 95 97 /// 96 98 /// </summary> 97 99 [TestMethod] 98 [TestCategory(" Problems.TestFunctions.MultiObjective")]100 [TestCategory("Analysis.MultiObjective")] 99 101 [TestProperty("Time", "short")] 100 102 public void HypervolumeTestRandomSinglePoint() { … … 114 116 referencePoint[0] = 1; 115 117 referencePoint[1] = 1; 116 double ne = Hypervolume .Calculate(front, referencePoint, maximization);117 118 //NorthWest 119 maximization = new bool[] { true, false }; 120 referencePoint[0] = 0; 121 referencePoint[1] = 1; 122 double nw = Hypervolume .Calculate(front, referencePoint, maximization);123 124 //SouthWest 125 maximization = new bool[] { true, true }; 126 referencePoint[0] = 0; 127 referencePoint[1] = 0; 128 double sw = Hypervolume .Calculate(front, referencePoint, maximization);129 130 //SouthEast 131 maximization = new bool[] { false, true }; 132 referencePoint[0] = 1; 133 referencePoint[1] = 0; 134 double se = Hypervolume .Calculate(front, referencePoint, maximization);118 double ne = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 119 120 //NorthWest 121 maximization = new bool[] { true, false }; 122 referencePoint[0] = 0; 123 referencePoint[1] = 1; 124 double nw = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 125 126 //SouthWest 127 maximization = new bool[] { true, true }; 128 referencePoint[0] = 0; 129 referencePoint[1] = 0; 130 double sw = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 131 132 //SouthEast 133 maximization = new bool[] { false, true }; 134 referencePoint[0] = 1; 135 referencePoint[1] = 0; 136 double se = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 135 137 Assert.AreEqual(1.0, ne + se + nw + sw, 1e8); 136 138 } … … 144 146 /// +-----x 145 147 /// 146 /// box between(0,0) and(1,1) with three point ( pareto) front at (1,0), (0.5,0.5) and (0,1)147 /// Hypervolume to (1,0) and (0,1) of the corners should be 1 (dominated Points need to be re emoved beforehand and148 /// box between(0,0) and(1,1) with three point (Pareto) front at (1,0), (0.5,0.5) and (0,1) 149 /// Hypervolume to (1,0) and (0,1) of the corners should be 1 (dominated Points need to be removed beforehand and 148 150 /// Hypervolume to (0,0) and (1,1) of the corners should be 0.25 149 151 /// </summary> 150 152 [TestMethod] 151 [TestCategory(" Problems.TestFunctions.MultiObjective")]153 [TestCategory("Analysis.MultiObjective")] 152 154 [TestProperty("Time", "short")] 153 155 public void HypervolumeTestDiagonalPoint() { … … 171 173 referencePoint[0] = 1; 172 174 referencePoint[1] = 1; 173 double ne = Hypervolume .Calculate(front, referencePoint, maximization);175 double ne = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 174 176 Assert.AreEqual(0.25, ne); 175 177 … … 178 180 referencePoint[0] = 0; 179 181 referencePoint[1] = 1; 180 double nw = Hypervolume.Calculate(NonDominatedSelect.SelectNonDominatedVectors(front, maximization, true), referencePoint, maximization); 182 var nonDominatedFront = DominationCalculator.CalculateBestParetoFront(front, front, maximization, false).Select(i => i.Item2).ToList(); 183 double nw = HypervolumeCalculator.CalculateHypervolume(nonDominatedFront, referencePoint, maximization); 181 184 Assert.AreEqual(1, nw); 182 185 … … 185 188 referencePoint[0] = 0; 186 189 referencePoint[1] = 0; 187 double sw = Hypervolume .Calculate(front, referencePoint, maximization);190 double sw = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 188 191 Assert.AreEqual(0.25, sw); 189 192 … … 192 195 referencePoint[0] = 1; 193 196 referencePoint[1] = 0; 194 double se = Hypervolume.Calculate(NonDominatedSelect.SelectNonDominatedVectors(front, maximization, true), referencePoint, maximization); 197 nonDominatedFront = DominationCalculator.CalculateBestParetoFront(front, front, maximization, false).Select(i => i.Item2).ToList(); 198 double se = HypervolumeCalculator.CalculateHypervolume(nonDominatedFront, referencePoint, maximization); 195 199 Assert.AreEqual(1, se); 196 200 … … 199 203 [TestMethod()] 200 204 [ExpectedException(typeof(ArgumentException))] 201 [TestCategory(" Problems.TestFunctions.MultiObjective")]205 [TestCategory("Analysis.MultiObjective")] 202 206 [TestProperty("Time", "short")] 203 207 public void HypervolumeTestReferencePointViolationNE() { … … 215 219 referencePoint[0] = 1; 216 220 referencePoint[1] = 1; 217 double ne = Hypervolume .Calculate(front, referencePoint, maximization);218 } 219 220 [TestMethod()] 221 [ExpectedException(typeof(ArgumentException))] 222 [TestCategory(" Problems.TestFunctions.MultiObjective")]221 double ne = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 222 } 223 224 [TestMethod()] 225 [ExpectedException(typeof(ArgumentException))] 226 [TestCategory("Analysis.MultiObjective")] 223 227 [TestProperty("Time", "short")] 224 228 public void HypervolumeTestReferencePointViolationNW() { … … 236 240 referencePoint[0] = 0; 237 241 referencePoint[1] = 1; 238 double nw = Hypervolume .Calculate(front, referencePoint, maximization);242 double nw = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 239 243 Assert.AreEqual(0.25, nw); 240 244 } … … 242 246 [TestMethod()] 243 247 [ExpectedException(typeof(ArgumentException))] 244 [TestCategory(" Problems.TestFunctions.MultiObjective")]248 [TestCategory("Analysis.MultiObjective")] 245 249 [TestProperty("Time", "short")] 246 250 public void HypervolumeTestReferencePointViolationSW() { … … 258 262 referencePoint[0] = 0; 259 263 referencePoint[1] = 0; 260 double sw = Hypervolume .Calculate(front, referencePoint, maximization);264 double sw = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 261 265 Assert.AreEqual(0.25, sw); 262 266 } … … 264 268 [TestMethod()] 265 269 [ExpectedException(typeof(ArgumentException))] 266 [TestCategory(" Problems.TestFunctions.MultiObjective")]270 [TestCategory("Analysis.MultiObjective")] 267 271 [TestProperty("Time", "short")] 268 272 public void HypervolumeTestReferencePointViolationSE() { … … 280 284 referencePoint[0] = 1; 281 285 referencePoint[1] = 0; 282 double se = Hypervolume .Calculate(front, referencePoint, maximization);286 double se = HypervolumeCalculator.CalculateHypervolume(front, referencePoint, maximization); 283 287 Assert.AreEqual(0.25, se); 284 288 } -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/Multi-objective/InvertedGenerationalDistanceTest.cs
r17261 r17262 22 22 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 23 24 namespace HeuristicLab. Problems.TestFunctions.MultiObjective.Tests {24 namespace HeuristicLab.Analysis.MultiObjective.Tests { 25 25 [TestClass] 26 26 public class InvertedGenerationalDistanceTest { … … 28 28 [TestMethod] 29 29 [ExpectedException(typeof(ArgumentException))] 30 [TestCategory(" Problems.TestFunctions.MultiObjective")]30 [TestCategory("Analysis.MultiObjective")] 31 31 [TestProperty("Time", "short")] 32 32 public void InvertedGenerationalDistanceTestEmptyOptimalFront() { … … 37 37 double[][] front = { point }; 38 38 double[][] referencefront = { }; 39 InvertedGenerationalDistance.Calculate(front, referencefront, 1);39 GenerationalDistanceAnalyzer.CalculateInverseGenerationalDistance(front, referencefront, 1); 40 40 } 41 41 42 42 [TestMethod] 43 43 [ExpectedException(typeof(ArgumentException))] 44 [TestCategory(" Problems.TestFunctions.MultiObjective")]44 [TestCategory("Analysis.MultiObjective")] 45 45 [TestProperty("Time", "short")] 46 46 public void InvertedGenerationalDistanceTestEmptyFront() { … … 51 51 double[][] front = { }; 52 52 double[][] referencefront = { point }; 53 InvertedGenerationalDistance.Calculate(front, referencefront, 1);53 GenerationalDistanceAnalyzer.CalculateInverseGenerationalDistance(front, referencefront, 1); 54 54 } 55 55 56 56 [TestMethod] 57 [TestCategory(" Problems.TestFunctions.MultiObjective")]57 [TestCategory("Analysis.MultiObjective")] 58 58 [TestProperty("Time", "short")] 59 59 public void InvertedGenerationalDistanceTestSamePoint() { … … 66 66 point1[1] = 0.5; 67 67 double[][] referencefront = { point1 }; 68 double dist = GenerationalDistance .Calculate(front, referencefront, 1);68 double dist = GenerationalDistanceAnalyzer.CalculateInverseGenerationalDistance(front, referencefront, 1); 69 69 Assert.AreEqual(0, dist); 70 70 } 71 71 72 72 [TestMethod] 73 [TestCategory(" Problems.TestFunctions.MultiObjective")]73 [TestCategory("Analysis.MultiObjective")] 74 74 [TestProperty("Time", "short")] 75 75 public void InvertedGenerationalDistanceTestSinglePoint() { … … 82 82 point2[1] = 1; 83 83 double[][] referencefront = { point2 }; 84 double dist = InvertedGenerationalDistance.Calculate(front, referencefront, 1);84 double dist = GenerationalDistanceAnalyzer.CalculateInverseGenerationalDistance(front, referencefront, 1); 85 85 Assert.AreEqual(Math.Sqrt(2), dist); 86 86 } 87 87 88 88 [TestMethod] 89 [TestCategory(" Problems.TestFunctions.MultiObjective")]89 [TestCategory("Analysis.MultiObjective")] 90 90 [TestProperty("Time", "short")] 91 91 public void InvertedGenerationalDistanceTestDifferentSizes() { … … 101 101 point2[1] = 0; 102 102 double[][] referencefront = { point2 }; 103 double dist = InvertedGenerationalDistance.Calculate(front, referencefront, 1);103 double dist = GenerationalDistanceAnalyzer.CalculateInverseGenerationalDistance(front, referencefront, 1); 104 104 Assert.AreEqual(0.5, dist); 105 105 } 106 106 107 107 [TestMethod] 108 [TestCategory(" Problems.TestFunctions.MultiObjective")]108 [TestCategory("Analysis.MultiObjective")] 109 109 [TestProperty("Time", "short")] 110 110 public void InvertedGenerationalDistanceTestQuadratic() { … … 123 123 point3[1] = 1; 124 124 double[][] referencefront = { point2, point3 }; 125 double dist = InvertedGenerationalDistance.Calculate(front, referencefront, 1);125 double dist = GenerationalDistanceAnalyzer.CalculateInverseGenerationalDistance(front, referencefront, 1); 126 126 Assert.AreEqual(1, dist); 127 127 } -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Analysis-3.3/Multi-objective/SpacingTest.cs
r17261 r17262 22 22 using Microsoft.VisualStudio.TestTools.UnitTesting; 23 23 24 namespace HeuristicLab. Problems.TestFunctions.MultiObjective.Tests {24 namespace HeuristicLab.Analysis.MultiObjective.Tests { 25 25 [TestClass] 26 26 public class SpacingTest { 27 27 [TestMethod] 28 28 [ExpectedException(typeof(ArgumentException))] 29 [TestCategory(" Problems.TestFunctions.MultiObjective")]29 [TestCategory("Analysis.MultiObjective")] 30 30 [TestProperty("Time", "short")] 31 31 public void SpacingTestEmptyFront() { 32 32 double[][] front = { }; 33 33 34 Spacing .Calculate(front);34 SpacingAnalyzer.CalculateSpacing(front); 35 35 } 36 36 37 37 [TestMethod] 38 [TestCategory(" Problems.TestFunctions.MultiObjective")]38 [TestCategory("Analysis.MultiObjective")] 39 39 [TestProperty("Time", "short")] 40 40 public void SpacingTestSamePoint() { … … 48 48 point1[1] = 0.5; 49 49 double[][] front = { point, point1 }; 50 double dist = Spacing .Calculate(front);50 double dist = SpacingAnalyzer.CalculateSpacing(front); 51 51 Assert.AreEqual(0, dist); 52 52 } 53 53 54 54 [TestMethod] 55 [TestCategory(" Problems.TestFunctions.MultiObjective")]55 [TestCategory("Analysis.MultiObjective")] 56 56 [TestProperty("Time", "short")] 57 57 public void SpacingTestSinglePoint() { … … 60 60 point[1] = 0; 61 61 double[][] front = { point }; 62 double dist = Spacing .Calculate(front);62 double dist = SpacingAnalyzer.CalculateSpacing(front); 63 63 Assert.AreEqual(0, dist); 64 64 } 65 65 66 66 [TestMethod] 67 [TestCategory(" Problems.TestFunctions.MultiObjective")]67 [TestCategory("Analysis.MultiObjective")] 68 68 [TestProperty("Time", "short")] 69 69 public void SpacingTestQuadratic() { … … 82 82 point3[1] = 1; 83 83 double[][] front = { point, point1, point2, point3 }; 84 double dist = Spacing .Calculate(front);84 double dist = SpacingAnalyzer.CalculateSpacing(front); 85 85 Assert.AreEqual(0, dist); 86 86 } 87 87 88 88 [TestMethod] 89 [TestCategory(" Problems.TestFunctions.MultiObjective")]89 [TestCategory("Analysis.MultiObjective")] 90 90 [TestProperty("Time", "short")] 91 91 public void SpacingTestRectangular() { … … 104 104 point3[1] = 1; 105 105 double[][] front = { point, point1, point2, point3 }; 106 double dist = Spacing .Calculate(front);106 double dist = SpacingAnalyzer.CalculateSpacing(front); 107 107 Assert.AreEqual(0, dist); 108 108 } … … 111 111 /// deltoid with 3 points of the 1-unit-square and the northeastern point at 4,4 112 112 /// which gives d=(1,1,1,5) for minimal distances. Mean of d is 2 and variance of d is 3 113 /// Spacing is defined as the standard deviation of d113 /// Spacing is defined as the standard deviation of d 114 114 /// </summary> 115 115 [TestMethod] 116 [TestCategory(" Problems.TestFunctions.MultiObjective")]116 [TestCategory("Analysis.MultiObjective")] 117 117 [TestProperty("Time", "short")] 118 118 public void SpacingTestDeltoid() { … … 131 131 point3[1] = 4; 132 132 double[][] front = { point, point1, point2, point3 }; 133 double dist = Spacing .Calculate(front);133 double dist = SpacingAnalyzer.CalculateSpacing(front); 134 134 Assert.AreEqual(Math.Sqrt(3), dist); 135 135 } -
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r17226 r17262 636 636 <Compile Include="HeuristicLab.Problems.TestFunctions-3.3\SumSquaresEvaluatorTest.cs" /> 637 637 <Compile Include="HeuristicLab.Problems.TestFunctions-3.3\ZakharovEvaluatorTest.cs" /> 638 <Compile Include="HeuristicLab. Problems.TestFunctions.MultiObjective-3.3\CrowdingTest.cs" />639 <Compile Include="HeuristicLab. Problems.TestFunctions.MultiObjective-3.3\FastHyperVolumeTests.cs" />640 <Compile Include="HeuristicLab. Problems.TestFunctions.MultiObjective-3.3\GenerationalDistanceTest.cs" />641 <Compile Include="HeuristicLab. Problems.TestFunctions.MultiObjective-3.3\HyperVolumeTests.cs" />642 <Compile Include="HeuristicLab. Problems.TestFunctions.MultiObjective-3.3\InvertedGenerationalDistanceTest.cs" />643 <Compile Include="HeuristicLab. Problems.TestFunctions.MultiObjective-3.3\SpacingTest.cs" />638 <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\CrowdingTest.cs" /> 639 <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\FastHyperVolumeTests.cs" /> 640 <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\GenerationalDistanceTest.cs" /> 641 <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\HyperVolumeTests.cs" /> 642 <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\InvertedGenerationalDistanceTest.cs" /> 643 <Compile Include="HeuristicLab.Analysis-3.3\Multi-objective\SpacingTest.cs" /> 644 644 <Compile Include="HeuristicLab.Problems.TravelingSalesman-3.3\TSPMoveEvaluatorTest.cs" /> 645 645 <Compile Include="HeuristicLab.Problems.LinearAssignment-3.3\LinearAssignmentProblemSolverTest.cs" />
Note: See TracChangeset
for help on using the changeset viewer.