示例#1
0
        public void Test_Gen_outbound_TF_Demand_method()
        {
            TF_Demand demand = new TF_Demand(720, 5);

            int[,] A = { { 00, 01, 02, 03, 04 },
                         { 10, 11, 12, 13, 14 },
                         { 20, 21, 22, 23, 24 },
                         { 30, 31, 32, 33, 34 },
                         { 40, 41, 42, 43, 44 } };
            demand.demand[0] = A;
            TF_Demand outbound_demand = demand.Gen_Outbound_demand();

            int[,] expected =
            {
                { 0, 01, 02, 03, 04 },
                { 0,  0, 12, 13, 14 },
                { 0,  0,  0, 23, 24 },
                { 0,  0,  0,  0, 34 },
                { 0,  0,  0,  0,  0 }
            };
            for (int k = 0; k < 1; k++)
            {
                for (int i = 0; i < outbound_demand.dimension; i++)
                {
                    for (int j = 0; j < outbound_demand.dimension; j++)
                    {
                        Assert.AreEqual(expected[i, j], outbound_demand.demand[k][i, j]);
                    }
                }
            }
        }
示例#2
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);
        }
示例#3
0
        public void Test_sum_to_unserve_demand_unassign()
        {
            TF_Demand demand = new TF_Demand(720, 5);

            int[,] expected = demand.getDemand(1);
            demand.sum_to_unserve_demand(1);
            int[,] actual = demand.getDemand(1);
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Assert.AreEqual(expected[i, j], actual[i, j]);
                }
            }
        }
示例#4
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]);
                }
            }
        }
示例#5
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]);
                }
            }
        }