Beispiel #1
0
        public void ZeroMatrix()
        {
            var source = new ushort[][]
            {
                new ushort[] { 0, 0, 0, 0 },
                new ushort[] { 0, 0, 0, 0 },
                new ushort[] { 0, 0, 0, 0 },
                new ushort[] { 0, 0, 0, 0 },
            };

            const ushort MAX_PROBABILITY = 100;
            var          slicer          = new Mock <ISlicer>();
            var          secondary       = new Mock <IRowValleyOptimizer>();
            var          optimizer       = new MatrixOptimizer(slicer.Object, secondary.Object);


            ushort[] rowDenominators = new[] {
                MAX_PROBABILITY,
                MAX_PROBABILITY,
                MAX_PROBABILITY,
                MAX_PROBABILITY,
            };
            var solution = optimizer.Optimize(rowDenominators, source);

            Assert.IsNotNull(solution);
            Assert.IsNotNull(solution.Rows);
            Assert.IsTrue(solution.IsOptimized);

            foreach (var row in solution.Rows)
            {
                Assert.IsNotNull(row);
                Assert.AreEqual(SolutionType.NoOperation, row.Approach);
            }
        }
Beispiel #2
0
        public void Setup()
        {
            var source = new ushort[4, 4]
            {
                { 0, 1, 1, 1 },
                { 2, 0, 2, 2 },
                { 3, 3, 0, 3 },
                { 6, 6, 6, 0 },
            };

            var slicer    = new Mock <ISlicer>();
            var secondary = new Mock <IRowValleyOptimizer>();
            var optimizer = new MatrixOptimizer(slicer.Object, secondary.Object);

            var rowDenominators = new ushort[] { 3, 6, 9, 18 };

            mSolution = optimizer.Optimize(rowDenominators, source);
        }
Beispiel #3
0
        public void Setup()
        {
            var source = new ushort[4, 4]
            {
                { 1, 1, 1, 1 },   // EVEN ALL
                { 0, 1, 0, 0 },   // DEAD END
                { 0, 100, 0, 0 }, // REDIRECT
                { 0, 0, 0, 0 },   // NO-OP
            };

            var slicer    = new Mock <ISlicer>();
            var secondary = new Mock <IRowValleyOptimizer>();
            var optimizer = new MatrixOptimizer(slicer.Object, secondary.Object);

            var rowDenominators = new ushort[] { 4, 1, 100, 1 };

            mSolution = optimizer.Optimize(rowDenominators, source);
        }
Beispiel #4
0
        public void Setup()
        {
            var source = new ushort[4, 4]
            {
                { 1, 0, 0, 0 },
                { 0, 1, 0, 0 },
                { 0, 0, 1, 0 },
                { 0, 0, 0, 1 },
            };

            var slicer    = new Mock <ISlicer>();
            var secondary = new Mock <IRowValleyOptimizer>();
            var optimizer = new MatrixOptimizer(slicer.Object, secondary.Object);

            const ushort MaxProbability = 1;

            var rowDenominators = new[] { MaxProbability, MaxProbability, MaxProbability, MaxProbability };

            mSolution = optimizer.Optimize(rowDenominators, source);
        }
Beispiel #5
0
        public void IdentityMatrix()
        {
            var source = new ushort[4, 4]
            {
                { 1, 0, 0, 0 },
                { 0, 1, 0, 0 },
                { 0, 0, 1, 0 },
                { 0, 0, 0, 1 },
            };

            var slicer    = new Mock <ISlicer>();
            var secondary = new Mock <IRowValleyOptimizer>();
            var optimizer = new MatrixOptimizer(slicer.Object, secondary.Object);

            const ushort MaxProbability = 1;

            var rowDenominators = new[] { MaxProbability, MaxProbability, MaxProbability, MaxProbability };

            var solution = optimizer.Optimize(rowDenominators, source);

            Assert.IsNotNull(solution);

            Assert.AreEqual(4, solution.NoOfStates);
            Assert.IsNotNull(solution.Rows);
            Assert.IsTrue(solution.IsOptimized);

            // SHOULD BE ALL

            for (var i = 0; i < 4; i++)
            {
                var row = solution.Rows[i];
                Assert.IsNotNull(row);
                Assert.AreEqual(SolutionType.DeadEnd, row.Approach);
                Assert.AreEqual(i, row.Branch);
            }
        }