- Timestamp:
- 11/04/13 10:18:18 (11 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/AlgorithmBehaviorUnitTests.csproj
r10090 r10104 48 48 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.PermutationEncoding-3.3.dll</HintPath> 49 49 </Reference> 50 <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 51 <SpecificVersion>False</SpecificVersion> 52 <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath> 53 <Private>True</Private> 54 </Reference> 50 55 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 51 56 <SpecificVersion>False</SpecificVersion> … … 86 91 <Compile Include="Properties\AssemblyInfo.cs" /> 87 92 <Compile Include="ConvexHullTest.cs" /> 93 <Compile Include="RealVectorSolutionCacheTest.cs" /> 88 94 </ItemGroup> 89 95 <ItemGroup> -
branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/PermutationCacheTest.cs
r10060 r10104 34 34 PermutationEqualityComparer comp = new PermutationEqualityComparer(); 35 35 PermutationSolutionCache dict = new PermutationSolutionCache(); 36 int realDuplicates = 0; 37 int noDuplicates = 0; 36 int nrOfPermutations = 200; 38 37 39 Permutation[] permutations = new Permutation[500]; 40 for (int i = 0; i < permutations.Length; i += 2) {38 39 for (int i = 0; i < nrOfPermutations; i++) { 41 40 var p = new Permutation(PermutationTypes.RelativeUndirected, 21, rand); 42 permutations[i] = p;43 permutations[i + 1] = p;44 41 42 //should be added 45 43 PermutationSolutionInformation pi = new PermutationSolutionInformation(); 46 pi.Generation = rand.Next(0, 100);44 pi.Generation = 9; 47 45 pi.ProducedBy = ProducedBy.Mutation; 46 dict.Add(p, pi); 48 47 48 //should be added 49 pi = new PermutationSolutionInformation(); 50 pi.Generation = 10; 51 pi.ProducedBy = ProducedBy.Mutation; 52 dict.Add(p, pi); 53 54 //should be added 55 pi = new PermutationSolutionInformation(); 56 pi.Generation = 10; 57 pi.ProducedBy = ProducedBy.Crossover; 58 dict.Add(p, pi); 59 60 //should not be added 61 pi = new PermutationSolutionInformation(); 62 pi.Generation = 10; 63 pi.ProducedBy = ProducedBy.Mutation; 49 64 dict.Add(p, pi); 50 65 } 51 66 52 for (int i = 0; i < permutations.Length; i++) { 53 for (int j = i + 1; j < permutations.Length; j++) { 54 if (comp.Equals(permutations[i], permutations[j])) { 55 realDuplicates++; 56 break; 57 } 58 } 67 foreach (var value in dict.Values()) { 68 Assert.AreEqual(3, value.Count); 59 69 } 60 70 61 for (int i = 0; i < dict.SolutionDictionary.Keys.Count; i++) { 62 for (int j = i + 1; j < dict.SolutionDictionary.Keys.Count; j++) { 63 if (comp.Equals(dict.SolutionDictionary.Keys.ElementAt(i), dict.SolutionDictionary.Keys.ElementAt(j))) { 64 noDuplicates++; 65 break; 66 } 67 } 71 foreach (var key in dict.Keys()) { 72 int cnt = dict.Keys().Count(x => comp.Equals(key, x)); 73 Assert.AreEqual(1, cnt); 68 74 } 69 70 Assert.AreNotEqual(0, realDuplicates);71 Assert.AreEqual(0, noDuplicates);72 Assert.AreEqual(250, dict.SolutionDictionary.Keys.Count);73 75 } 74 76 }
Note: See TracChangeset
for help on using the changeset viewer.