Changeset 17691
- Timestamp:
- 07/22/20 12:52:51 (4 years ago)
- Location:
- branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3-3.3.Test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3-3.3.Test/HeuristicLab.Algorithms.NSGA3-3.3.Test.csproj
r17666 r17691 40 40 </PropertyGroup> 41 41 <ItemGroup> 42 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec" /> 43 <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec" /> 42 44 <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> 43 45 <HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> -
branches/2825-NSGA3/HeuristicLab.Algorithms.NSGA3-3.3.Test/UtilityTests.cs
r17667 r17691 1 1 using System; 2 using System.Collections.Generic; 2 3 using HeuristicLab.Algorithms.NSGA3; 4 using HeuristicLab.Encodings.RealVectorEncoding; 3 5 using Microsoft.VisualStudio.TestTools.UnitTesting; 4 6 … … 36 38 Assert.AreEqual(result, Utility.NCR(n, r)); 37 39 } 40 41 [DataTestMethod] 42 public void TestToFitnessMatrix() 43 { 44 Solution solution1 = new Solution(new RealVector()); 45 Solution solution2 = new Solution(new RealVector()); 46 Solution solution3 = new Solution(new RealVector()); 47 Solution solution4 = new Solution(new RealVector()); 48 49 solution1.Fitness = new double[] { 1.0, 2.0, 3.0 }; 50 solution2.Fitness = new double[] { 4.0, 5.0, 6.0 }; 51 solution3.Fitness = new double[] { 7.0, 8.0, 9.0 }; 52 solution4.Fitness = new double[] { 10.0, 11.0, 12.0 }; 53 54 var fitnessMatrix = Utility.ToFitnessMatrix(new List<Solution>() { solution1, solution2, solution3, solution4 }); 55 56 Assert.AreEqual(1.0, fitnessMatrix[0][0]); 57 Assert.AreEqual(5.0, fitnessMatrix[1][1]); 58 Assert.AreEqual(9.0, fitnessMatrix[2][2]); 59 Assert.AreEqual(2.0, fitnessMatrix[0][1]); 60 Assert.AreEqual(4.0, fitnessMatrix[1][0]); 61 Assert.AreEqual(10.0, fitnessMatrix[3][0]); 62 Assert.AreEqual(12.0, fitnessMatrix[3][2]); 63 } 64 65 [TestMethod] 66 public void TestConcat() 67 { 68 List<int> ints1 = new List<int>() { 1, 2, 3, 4 }; 69 List<int> ints2 = new List<int>() { 5, 6, 7, 8 }; 70 71 List<int> concatList = Utility.Concat(ints1, ints2); 72 Assert.AreEqual(8, concatList.Count); 73 List<int> ints3 = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 }; 74 for (int i = 0; i < ints3.Count; i++) 75 { 76 Assert.AreEqual(ints3[i], concatList[i]); 77 } 78 } 79 80 [DataTestMethod] 81 public void TestMinArgMin() 82 { 83 List<int> ints = new List<int>() { 3, 4, 5, 1, 2 }; 84 var result = Utility.MinArgMin(i => 2 * i, ints); 85 Assert.AreEqual(1, result.Item1); 86 Assert.AreEqual(2, result.Item2); 87 } 88 89 [DataTestMethod] 90 public void TestMaxArgMax() 91 { 92 List<int> ints = new List<int>() { 3, 4, 5, 1, 2 }; 93 var result = Utility.MaxArgMax(i => 2 * i, ints); 94 Assert.AreEqual(5, result.Item1); 95 Assert.AreEqual(10, result.Item2); 96 } 97 98 [DataTestMethod] 99 public void TestMin() 100 { 101 List<int> ints = new List<int>() { 3, 4, 5, 1, 2 }; 102 Assert.AreEqual(2, Utility.Min(i => 2 * i, ints)); 103 } 104 105 [DataTestMethod] 106 public void TestMax() 107 { 108 List<int> ints = new List<int>() { 3, 4, 5, 1, 2 }; 109 Assert.AreEqual(10, Utility.Max(i => 2 * i, ints)); 110 } 111 112 [DataTestMethod] 113 public void TestArgMin() 114 { 115 List<int> ints = new List<int>() { 3, 4, 5, 1, 2 }; 116 Assert.AreEqual(1, Utility.ArgMin(i => 2 * i, ints)); 117 } 118 119 [DataTestMethod] 120 public void TestArgMax() 121 { 122 List<int> ints = new List<int>() { 3, 4, 5, 1, 2 }; 123 Assert.AreEqual(5, Utility.ArgMax(i => 2 * i, ints)); 124 } 38 125 } 39 126 }
Note: See TracChangeset
for help on using the changeset viewer.