Ejemplo n.º 1
0
        private static void RandomTestA(Random rand)
        {
            int lines     = 2;
            int nodeCount = rand.Next(1, 20);
            int min       = 1;
            int max       = 100000;

            long[] enter = new long[lines];
            long[] exit  = new long[lines];
            long[,] stationCost = new long[lines, nodeCount];
            long[,] switchCost  = new long[lines, nodeCount - 1];

            for (int i = 0; i < lines; i++)
            {
                enter[i] = rand.Next(min, max);
                exit[i]  = rand.Next(min, max);

                for (int j = 0; j < nodeCount; j++)
                {
                    stationCost[i, j] = rand.Next(min, max);

                    if (j < nodeCount - 1)
                    {
                        switchCost[i, j] = rand.Next(min, max);
                    }
                }
            }

            AssemblyLineProblem target = new AssemblyLineProblem();

            target.Enter       = enter;
            target.Exit        = exit;
            target.StationCost = stationCost;
            target.SwitchCost  = switchCost;

            WriteInput(target);

            target.Solve(true);
            long expectedTime = target.MinTime;

            WritePath(target);

            target.Solve(false);
            long actualTime = target.MinTime;

            WritePath(target);

            Console.WriteLine("Expected = " + expectedTime.ToString());
            Console.WriteLine("Actual = " + actualTime.ToString());

            Assert.AreEqual(expectedTime, actualTime);
        }
Ejemplo n.º 2
0
        private static void Solve(long[] enter, long[] exit, long[,] stationCost, long[,] switchCost, long expectedTime, int[] expectedPath)
        {
            AssemblyLineProblem target = new AssemblyLineProblem();

            target.Enter       = enter;
            target.Exit        = exit;
            target.StationCost = stationCost;
            target.SwitchCost  = switchCost;

            target.Solve(false);

            Assert.AreEqual(expectedTime, target.MinTime);

            //CollectionAssert.AreEqual(expectedPath, target.Path);
        }
Ejemplo n.º 3
0
        public void RandomTestFailed()
        {
            long[] enter = new long[] { 10, 20 };
            long[] exit  = new long[] { 24, 5 };

            long[,] stationCost = new long[, ]
            {
                { 10, 20, 7, 38, 8, 9 },
                { 11, 2, 34, 52, 9, 10 }
            };

            long[,] switchCost = new long[, ]
            {
                { 2, 5, 100, 2, 88 },
                { 89, 23, 1, 23, 94 },
            };

            AssemblyLineProblem target = new AssemblyLineProblem();

            target.Enter       = enter;
            target.Exit        = exit;
            target.StationCost = stationCost;
            target.SwitchCost  = switchCost;

            target.Solve(true);
            long expectedTime = target.MinTime;

            WritePath(target);

            target.Solve(false);
            long actualTime = target.MinTime;

            WritePath(target);

            Assert.AreEqual(expectedTime, actualTime);
        }