예제 #1
0
        public void Test_cal_service_util_must_reply_index()
        {
            Train_obj train  = new Train_obj(200);
            TF_Demand demand = new TF_Demand(1440, 5, "test");

            int[,] outbound_demand = new int[5, 5];
            List <Service> outbound_services = new List <Service>();

            int[]        service  = { 1, 0, 1, 1, 1 };
            int[]        service2 = { 0, 0, 1, 0, 1 };
            int[]        service3 = { 1, 1, 1, 1, 1 };
            int[]        service4 = { 0, 1, 1, 1, 1 };
            List <int[]> test1    = new List <int[]>();

            test1.Add(service);
            test1.Add(service2);
            Service aService;

            aService = new Service("aaa", service);
            outbound_services.Add(aService);
            aService = new Service("3_station_outbound", service2);
            outbound_services.Add(aService);
            aService = new Service("2_station_outbound", service3);
            outbound_services.Add(aService);
            aService = new Service("4_station_outbound_start_at_1", service4);
            outbound_services.Add(aService);
            //outbound_demand = demand.getOutbound_demand(0);
            int actual   = Service_algo.cal_all_service_util(outbound_demand, train, outbound_services);
            int expected = 0;

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void Test_maxUtilze()
        {
            Train_obj train = new Train_obj(100);

            int[]   service  = { 1, 1, 1, 1, 0 };
            Service services = new Service("test", service);
            float   actual   = Service_algo.max_utilize_of_service(train.cap, services);
            float   expected = 8500;

            Assert.Equal(expected, actual);
        }
예제 #3
0
        public void Test_isDemandEmpty_Must_be_True()
        {
            int[,] demand =
            {
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0 }
            };

            bool actual = Service_algo.isDemandEmpty(demand);

            Assert.IsTrue(actual);
        }
예제 #4
0
        public void Test_isDemandEmpty_With_Service_10101()
        {
            int[]   service = { 1, 0, 1, 0, 1 };
            Service A       = new Service("test", service);

            int[,] demand =
            {
                { 0, 10,  0, 10,  0 },
                { 0,  0, 10, 10, 10 },
                { 0,  0,  0, 10,  0 },
                { 0,  0,  0,  0, 10 },
                { 0,  0,  0,  0,  0 }
            };

            bool actual = Service_algo.isDemandEmpty_with_service(demand, A);

            Assert.IsTrue(actual);
        }
예제 #5
0
        //[TestMethod]
        public void Train_service_all_station()
        {
            TF_Demand tfd = new TF_Demand(1440, 5, "TEST");

            int[,] demand =
            {
                {  0, 10, 10, 10, 10 },
                { 10,  0, 10, 10, 10 },
                { 10, 10,  0, 10, 10 },
                { 10, 10, 10,  0, 10 },
                { 10, 10, 10, 10,  0 }
            };

            tfd.demand[0] = demand;

            Train_obj train = new Train_obj(40);

            int[]          service_all_station = { 1, 1, 1, 1, 1 };
            List <Service> forward             = new List <Service>();
            Service        testService         = new Service("All_station_outbound", service_all_station);

            forward.Add(testService);

            int[,] expected =
            {
                {  0,  0,  0,  0, 0 },
                { 10,  0,  6,  7, 7 },
                { 10, 10,  0,  3, 3 },
                { 10, 10, 10,  0, 0 },
                { 10, 10, 10, 10, 0 }
            };
            Service_algo.test_orchestrator_of_service(tfd, train, forward);
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Assert.AreEqual(expected[i, j], tfd.demand[0][i, j]);
                }
            }
        }
예제 #6
0
        public void Train_service_4_station_no_overcap()
        {
            TF_Demand tfd = new TF_Demand(1440, 5, "TEST");

            int[,] demand =
            {
                {  0, 10, 10, 10, 10 },
                { 10,  0, 10, 10, 10 },
                { 10, 10,  0, 10, 10 },
                { 10, 10, 10,  0, 10 },
                { 10, 10, 10, 10,  0 }
            };

            tfd.demand[0] = demand;

            Train_obj train = new Train_obj(40);

            int[]          service_4_station = { 1, 1, 1, 0, 1 };
            List <Service> forward           = new List <Service>();
            Service        testService       = new Service("All_station_outbound", service_4_station);

            forward.Add(testService);

            int[,] expected =
            {
                {  0,  0,  0, 10,  0 },
                { 10,  0,  0, 10,  0 },
                { 10, 10,  0, 10,  0 },
                { 10, 10, 10,  0, 10 },
                { 10, 10, 10, 10,  0 }
            };
            Service_algo.Train_a_b_c_d_e(tfd, train, forward[0], 0);
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Assert.Equal(expected[i, j], tfd.demand[0][i, j]);
                }
            }
        }