Changeset 15192
- Timestamp:
- 07/11/17 11:31:07 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersVectorTest.cs
r15191 r15192 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.Linq; 25 using HeuristicLab.Encodings.RealVectorEncoding; 23 26 using HeuristicLab.IGraph.Wrappers; 24 27 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 104 107 [TestProperty("Time", "short")] 105 108 public void IGraphWrappersVectorShuffleTest() { 106 var different = 0;109 var different = new HashSet<RealVector>(new RealVectorEqualityComparer()); 107 110 for (var i = 0; i < 100; i++) { 108 111 using (var vector = new Vector(5)) { … … 113 116 vector.Shuffle(); 114 117 var result = vector.ToArray(); 115 if (!result.SequenceEqual(new double[] { 4, 4, 3, 1.5, -0.5 })) 116 different++; 118 different.Add(new RealVector(result)); 117 119 Assert.AreEqual(2, result.Count(x => x == 4)); 118 120 Assert.AreEqual(1, result.Count(x => x == 3)); … … 122 124 } 123 125 // There should be reasonable low probability that all 100 shuffles result in exactly the same vector 124 Assert.IsTrue(different > 0); 126 Assert.IsTrue(different.Count > 1); 127 Assert.IsTrue(different.Count <= 60); // there are a total of 60 different shuffles 5! / 2! 128 Console.WriteLine("Shuffle produced " + different.Count + " unique vectors"); 125 129 } 126 130
Note: See TracChangeset
for help on using the changeset viewer.