Beispiel #1
0
        public void Evaluate_Redirect_1()
        {
            const int EXPECTED_RESULT = 3;

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

            const int OTHER = 1;
            var       stats = new MatrixRowSummary
            {
                SelfPercent = null,
                Row         = OTHER,
                Clusters    = new[] {
                    new ValueCluster {
                        Value     = MAX_VALUE,
                        First     = EXPECTED_RESULT,
                        NoOfTimes = 1,
                    }
                },
                NoOfStates          = 2,
                NoOfNonZeroPercents = 1,
                NoOfZeroPercents    = 1
            };

            var result = optimizer.Evaluate(MAX_VALUE, stats);

            Assert.AreEqual(SolutionType.Redirect, result.Approach);
            Assert.AreEqual(EXPECTED_RESULT, result.Branch);
        }
Beispiel #2
0
        public void Evaluate_NoOperation()
        {
            var stats = new MatrixRowSummary
            {
                NoOfStates       = 4,
                NoOfZeroPercents = 4
            };

            const ushort ROW_DENOMINATOR = 0;
            var          slicer          = new Mock <ISlicer>();
            var          secondary       = new Mock <IRowValleyOptimizer>();
            var          optimizer       = new MatrixOptimizer(slicer.Object, secondary.Object);
            var          result          = optimizer.Evaluate(ROW_DENOMINATOR, stats);

            Assert.AreEqual(SolutionType.NoOperation, result.Approach);
        }
Beispiel #3
0
        public void Evaluate_Unoptimized_0()
        {
            const int PERCENT_0 = 60;
            const int PERCENT_1 = 35;
            const int PERCENT_2 = 3;
            const int PERCENT_3 = 2;

            var stats = new MatrixRowSummary
            {
                SelfPercent         = PERCENT_0,
                NoOfStates          = 4,
                NoOfNonZeroPercents = 4,
                NoOfZeroPercents    = 0,
                Clusters            = new ValueCluster[] {
                    new ValueCluster
                    {
                        Value = PERCENT_0,
                    },
                    new ValueCluster
                    {
                        Value = PERCENT_1,
                    },
                    new ValueCluster
                    {
                        Value = PERCENT_2,
                    },
                    new ValueCluster
                    {
                        Value = PERCENT_3,
                    },
                },
            };

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

            Assert.AreEqual(SolutionType.Unoptimized, result.Approach);
        }