Пример #1
0
        public void TestOptimizeToOneStock(double stock, double minLeftover, double maxLeftover, double[] orderLens, int[] orderNums, double[] expectedNewPttrnPopLens)
        {
            BarSets      orders  = initPattern(orderLens, orderNums);
            MinMaxSolver sut     = new MinMaxSolver(minLeftover, maxLeftover);
            BarSets      pattern = sut.optimizeToOneStock(stock, orders);

            pattern.sortAsc();

            Assert.Equal(expectedNewPttrnPopLens.Length, pattern.count());
            foreach (double expectedPopLen in expectedNewPttrnPopLens)
            {
                Assert.Equal(expectedPopLen, pattern.popLen());
            }
        }
Пример #2
0
        public void TestCalKnapsack(double stock, double minLeftover, double maxLeftover, double[] orderLens, int[] orderNums, double[] expectedNewPttrnPopLens)
        {
            BarSets orders = initPattern(orderLens, orderNums);
            BarSets ret    = MinMaxSolver.calKnapsack(stock, orders);

            ret.sortAsc();

            // Assert.Equal("", ret.ToString());
            Assert.Equal(expectedNewPttrnPopLens.Length, ret.count());
            foreach (double expectedPopLen in expectedNewPttrnPopLens)
            {
                Assert.Equal(expectedPopLen, ret.popLen());
            }
        }