public void TestPermutationFactorTrendAnalyseResult_One_And_Two_Element()
        {
            var fac1 = new Factor <int> {
                Left = new List <int> {
                    1, 2
                }, Right = new List <int> {
                    3, 4
                }
            };
            var fac2 = new Factor <int> {
                Left = new List <int> {
                    5, 6
                }, Right = new List <int> {
                    7, 8
                }
            };
            var ls1 = new List <Factor <int> > {
                fac1
            };
            var ls = new List <Factor <int> > {
                fac1, fac2
            };

            var lss = new List <List <Factor <int> > > {
                ls1, ls
            };
            var result = PermutationFactorTrend.TraversePermutationFactor(lss);

            Assert.IsTrue(result.Count == 2 * 4);
        }
        public void TestAnalyse_Empty()
        {
            var numbers = new List <byte>
            {
                1, 3, 6, 9, 1, 4, 2, 3, 1, 2, 5, 6, 8, 2, 3, 1
            };

            var fac1 = new Factor <byte> {
                Left = new List <byte> {
                    1, 2
                }, Right = new List <byte> {
                    3, 4
                }
            };
            var fac2 = new Factor <byte> {
                Left = new List <byte> {
                    5, 6
                }, Right = new List <byte> {
                    7, 8
                }
            };
            //var fac3 = new Factor<byte> { Left = new List<byte> { 1, 2 }, Right = new List<byte> { 3, 4 } };
            var permutationFactors = new List <Factor <byte> > {
                fac1, fac2
            };


            var result = new PermutationFactorTrend().Analyse(new PermutationFactorTrendAnalyseDto <byte>
            {
                Numbers             = numbers,
                PermutationFactors  = permutationFactors,
                NumbersTailCutCount = 6
            });
        }
        public void TestCountConsecutive()
        {
            var numbers = new List <byte>
            {
                1, 3, 6, 9, 1, 4, 2, 3, 1, 2, 5, 6, 8, 2, 3, 1
            };

            /*
             * 索引位置: 0    1    2    3    4    5    6    7    8    9    10   11   12   13   14   15
             * 号码列表: 1,   3,   6,   9,   1,   4,   2,   3,   1,   2,   5,   6,   8,   2,   3,   1
             * 连续次数:      1    0    0         1         2    0    0    0    0    0         1    0
             * 最大间隔:     -1    X    X         0         -1   X    X    X    X    X         1    X
             *
             */
            var factors = new List <List <byte> >
            {
                new List <byte> {
                    1, 2
                },
                new List <byte> {
                    3, 4
                }
            };

            var predictiveFactor = new List <byte> {
                5, 6
            };

            var cutCount = 6;
            var result   = PermutationFactorTrend.CountConsecutiveDistribution(numbers, factors, predictiveFactor);

            //有两个连续次数
            Assert.IsTrue(result.HistoricalConsecutiveTimes.Count == 2);

            //连续次数=1出现一次
            Assert.IsTrue(result.HistoricalConsecutiveTimes[1] == 2);

            //连续次数=2出现一次
            Assert.IsTrue(result.HistoricalConsecutiveTimes[2] == 1);


            numbers = new List <byte>
            {
                1, 3, 9, 1, 3, 1, 3, 1, 3, 6, 9, 1, 4, 2, 3, 1, 4, 5, 6, 8, 2, 3, 1
            };

            result = PermutationFactorTrend.CountConsecutiveDistribution(numbers, factors, predictiveFactor);

            //有两个连续次数
            Assert.IsTrue(result.HistoricalConsecutiveTimes.Count == 2);

            //连续次数=1出现一次
            Assert.IsTrue(result.HistoricalConsecutiveTimes[1] == 2);

            //连续次数=3出现2次
            Assert.IsTrue(result.HistoricalConsecutiveTimes[3] == 2);



            numbers = new List <byte>
            {
                1, 3, 9, 1, 3, 1, 3, 1, 3, 6, 9, 1, 4, 2, 3, 1, 4, 1, 4, 2, 3, 1, 4, 1, 4, 2, 3, 1, 4, 5, 6, 8, 2, 3, 1
            };

            result = PermutationFactorTrend.CountConsecutiveDistribution(numbers, factors, predictiveFactor);

            //有3个连续次数
            Assert.IsTrue(result.HistoricalConsecutiveTimes.Count == 3);

            //连续次数=1出现一次
            Assert.IsTrue(result.HistoricalConsecutiveTimes[1] == 2);

            //连续次数=3出现一次
            Assert.IsTrue(result.HistoricalConsecutiveTimes[3] == 1);

            //连续次数=9出现一次
            Assert.IsTrue(result.HistoricalConsecutiveTimes[9] == 1);
        }