Example #1
0
        public void UniformOnePositionManipulatorApplyTest()
        {
            TestRandom    random = new TestRandom();
            IntegerVector parent, expected;
            IntMatrix     bounds = new IntMatrix(1, 2);

            // The following test is not based on published examples
            random.Reset();
            random.IntNumbers = new int[] { 3, 3 };
            parent            = new IntegerVector(new int[] { 2, 2, 3, 5, 1 });
            expected          = new IntegerVector(new int[] { 2, 2, 3, 3, 1 });
            bounds[0, 0]      = 2;
            bounds[0, 1]      = 7;
            UniformOnePositionManipulator.Apply(random, parent, bounds);
            Assert.IsTrue(Auxiliary.IntegerVectorIsEqualByPosition(expected, parent));
        }
        public void UniformOnePositionManipulatorApplyTest()
        {
            TestRandom   random = new TestRandom();
            RealVector   parent, expected;
            DoubleMatrix bounds;

            // The following test is not based on published examples
            random.Reset();
            random.IntNumbers    = new int[] { 3 };
            random.DoubleNumbers = new double[] { 0.2 };
            parent   = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.5, 0.1 });
            expected = new RealVector(new double[] { 0.2, 0.2, 0.3, 0.3, 0.1 });
            bounds   = new DoubleMatrix(new double[, ] {
                { 0.2, 0.7 }
            });
            UniformOnePositionManipulator.Apply(random, parent, bounds);
            Assert.IsTrue(Auxiliary.RealVectorIsAlmostEqualByPosition(expected, parent));
        }
 public static void Apply(IRandom random, PRVEncoding individual)
 {
     UniformOnePositionManipulator.Apply(random, individual.PriorityRulesVector, new IntMatrix(new int[, ] {
         { 0, individual.NrOfRules.Value }
     }));
 }