Exemple #1
0
        private void CheckGroupCrossover(LinearLinkage parent1, LinearLinkage parent2, int[] expectedllee, double[] randomNumbers)
        {
            var expected = LinearLinkage.FromEndLinks(expectedllee);
            var random   = new TestRandom()
            {
                DoubleNumbers = randomNumbers
            };
            var child = GroupCrossover.Apply(random, parent1, parent2);

            Assert.IsTrue(Auxiliary.LinearLinkageIsEqualByPosition(expected, child), "Expected [{0}] but was [{1}]!", string.Join(", ", expected), string.Join(", ", child));
        }
 public void GroupsRoundtripTest()
 {
     foreach (var values in validForwardEncoding)
     {
         var expected = LinearLinkage.FromForwardLinks(values);
         var groups   = expected.GetGroups();
         var actual   = LinearLinkage.FromGroups(expected.Length, groups);
         Assert.IsTrue(Auxiliary.LinearLinkageIsEqualByPosition(expected, actual),
                       "[{0}] did not roundtrip successfully!", string.Join(", ", values));
     }
 }
Exemple #3
0
        public void EqualParentsTest()
        {
            var random = new FastRandom(0);
            var parent = LinearLinkage.SingleElementGroups(10);
            var child  = GroupCrossover.Apply(random, parent, parent);

            Assert.IsTrue(Auxiliary.LinearLinkageIsEqualByPosition(parent, child));

            parent = RandomLinearLinkageCreator.Apply(random, 10);
            child  = GroupCrossover.Apply(random, parent, parent);
            Assert.IsTrue(Auxiliary.LinearLinkageIsEqualByPosition(parent, child));
        }