public void ByteMutation_ValueAddedConstructorTest()
        {
            int added = 2;
            ByteMutation_ValueAdded target = new ByteMutation_ValueAdded(added);

            Assert.AreEqual(target.Type, OperatorType.Byte);
        }
        public void MutateTest()
        {
            int added = 2;
            ByteMutation_ValueAdded target = new ByteMutation_ValueAdded(added);
            Point point = new BytePoint(10);
            Point actual;

            actual = target.Mutate(point);
            Assert.IsTrue(actual.StringRepresent().Equals("[12]") || actual.StringRepresent().Equals("[8]"));
        }
Beispiel #3
0
        private void SetByteDefaults()
        {
            Initialization = new ByteInitialization_Regular(10, 5);
            SelectionIF S  = new Selection_Tournament();
            CrossoverIF C  = new ByteCrossover_RandomOR();
            MutationIF  M1 = new ByteMutation_Shifts(1);
            MutationIF  M2 = new ByteMutation_ValueAdded(2);

            Operations.Add(S);
            Operations.Add(C);
            Operations.Add(M1);
            Operations.Add(M2);
        }
        public void OperateTest()
        {
            int added = 2;
            ByteMutation_ValueAdded target = new ByteMutation_ValueAdded(added);
            BytePoint p1 = new BytePoint(new byte[] { 1, 2, 3, 4 });
            BytePoint p2 = new BytePoint(new byte[] { 17, 2, 3, 46 });
            BytePoint p3 = new BytePoint(new byte[] { 4, 2, 36, 4 });
            BytePoint p4 = new BytePoint(new byte[] { 7, 26, 3, 4 });
            BytePoint p5 = new BytePoint(new byte[] { 35, 2, 33, 4 });

            PointSet expected = new PointSet(new HashSet <Point>()
            {
                p1, p2, p3, p4, p5
            });

            PointSet pointSet = new PointSet(new HashSet <Point>()
            {
                p1, p2, p3, p4, p5
            });
            PointSet actual;

            actual = target.Operate(pointSet);
            Assert.AreEqual(expected.Set.Count, actual.Set.Count);
        }