예제 #1
0
 private void AssertEqual(RailwayStation station, RailwayStationDto dto)
 {
     Assert.Equal(station.Id, dto.Id);
     Assert.Equal(station.Name, dto.Name);
     Assert.Equal(station.NumberOfPlatforms, dto.NumberOfPlatforms);
     AssertEqual(station.Location, dto.Location);
 }
        public void Test()
        {
            Booking booking = new Ctrip();
            Booking railway = new RailwayStation();

            Assert.Equal(railway.BuyTicket(), booking.BuyTicket());
        }
예제 #3
0
        public void UpdateLinkTarget()
        {
            RailwayStation nextStation = null;

            Point nextPoint = GetNextPoint();

            if (nextPoint != null)
            {
                nextStation = nextPoint.station;
            }

            station.LinkTo(nextStation);
        }
예제 #4
0
 public void LinkTo(RailwayStation targetStation)
 {
     m_LinkStation = targetStation;
     UpdateLink();
 }
예제 #5
0
        /*
         * 路网       A----------B----------C
         * 列车1      A---30m--->B---30m--->C
         * 列车2                 B---40m--->C
         * 价格等级   {0.9, 1, 1.1}
         * 旅客       A--------->B
         *            A-------------------->C
         *                       B--------->C
         * 预售期长度 11
         * 区间单价   20
         * 时间成本   1
         */
        private static RnsmWorkspace GenerateWorkspace()
        {
            //Build a RNSM workspace
            RnsmWorkspace wor = new RnsmWorkspace();

            #region Build railway netowrk
            wor.Net = new RailwayNetwork();
            //Build stations
            wor.Net.RailwayStations = new List <RailwayStation>();
            RailwayStation sta_A = new RailwayStation()
            {
                RailwayStationID = 1, StaName = "A"
            };
            RailwayStation sta_B = new RailwayStation()
            {
                RailwayStationID = 2, StaName = "B"
            };
            RailwayStation sta_C = new RailwayStation()
            {
                RailwayStationID = 3, StaName = "C"
            };
            wor.Net.RailwayStations.Add(sta_A);
            wor.Net.RailwayStations.Add(sta_B);
            wor.Net.RailwayStations.Add(sta_C);
            //Build sections
            wor.Net.RailwaySections = new List <RailwaySection>();
            wor.Net.RailwaySections.Add(new RailwaySection()
            {
                StartStation     = sta_A,
                EndStation       = sta_B,
                RailwaySectionID = 1
            });
            wor.Net.RailwaySections.Add(new RailwaySection()
            {
                StartStation     = sta_B,
                EndStation       = sta_C,
                RailwaySectionID = 2
            });
            #endregion

            #region Generate a timetable
            wor.RailwayTimeTable = new TrainDiagram();
            wor.RailwayTimeTable.Add(new TrainTrip
            {
                Name        = "Train01",
                StopStaions = new List <StopStation>
                {
                    new StopStation()
                    {
                        Station = sta_A,
                        DepTime = new DateTime(1991, 7, 5, 8, 0, 0)
                    },
                    new StopStation()
                    {
                        Station = sta_B,
                        ArrTime = new DateTime(1991, 7, 5, 8, 30, 0),
                        DepTime = new DateTime(1991, 7, 5, 8, 35, 0)
                    },
                    new StopStation()
                    {
                        Station = sta_C,
                        ArrTime = new DateTime(1991, 7, 5, 9, 5, 0)
                    },
                },
                ServiceSegments = new List <ServiceSegment>
                {
                    new ServiceSegment()
                    {
                        DepStation = sta_A,
                        DepTime    = new DateTime(1991, 7, 5, 8, 0, 0),
                        ArrStation = sta_B,
                        ArrTime    = new DateTime(1991, 7, 5, 8, 30, 0)
                    },
                    new ServiceSegment()
                    {
                        DepStation = sta_B,
                        DepTime    = new DateTime(1991, 7, 5, 8, 35, 0),
                        ArrStation = sta_C,
                        ArrTime    = new DateTime(1991, 7, 5, 9, 5, 0)
                    }
                }
            });//Train 1
            wor.RailwayTimeTable.Add(new TrainTrip
            {
                Name            = "Train02",
                StopStaions     = new List <StopStation>(),
                ServiceSegments = new List <ServiceSegment>
                {
                    new ServiceSegment()
                    {
                        DepStation = sta_B,
                        DepTime    = new DateTime(1991, 7, 5, 9, 0, 0),
                        ArrStation = sta_C,
                        ArrTime    = new DateTime(1991, 7, 5, 9, 40, 0),
                    }
                }
            });//Train 2
            #endregion

            #region Generate demand
            wor.Mar             = new RailwayMarket();
            wor.Mar.TimeHorizon = 10;
            (wor.Mar as List <RailwayMarketSegment>).AddRange(new List <RailwayMarketSegment>()
            {
                new RailwayMarketSegment
                {
                    MSID        = 1,
                    Description = "A->B",
                    OriSta      = sta_A,
                    DesSta      = sta_B
                },
                new RailwayMarketSegment
                {
                    MSID        = 2,
                    Description = "B->C",
                    OriSta      = sta_B,
                    DesSta      = sta_C
                },
                new RailwayMarketSegment
                {
                    MSID        = 3,
                    Description = "A->C",
                    OriSta      = sta_A,
                    DesSta      = sta_C,
                }
            });
            #endregion

            return(wor);
        }
예제 #6
0
        private static IRnsmWorkspace GenerateWorkspace1()
        {
            //Build a RNSM workspace
            RnsmWorkspace wor = new RnsmWorkspace();

            #region Build railway netowrk
            wor.Net = new RailwayNetwork();
            //Build stations
            wor.Net.RailwayStations = new List <RailwayStation>();
            RailwayStation sta_A = new RailwayStation()
            {
                RailwayStationID = 1, StaName = "A"
            };
            RailwayStation sta_B = new RailwayStation()
            {
                RailwayStationID = 2, StaName = "B"
            };
            RailwayStation sta_C = new RailwayStation()
            {
                RailwayStationID = 3, StaName = "C"
            };
            wor.Net.RailwayStations.Add(sta_A);
            wor.Net.RailwayStations.Add(sta_B);
            wor.Net.RailwayStations.Add(sta_C);
            //Build sections
            wor.Net.RailwaySections = new List <RailwaySection>();
            wor.Net.RailwaySections.Add(new RailwaySection()
            {
                StartStation     = sta_A,
                EndStation       = sta_B,
                RailwaySectionID = 1
            });
            wor.Net.RailwaySections.Add(new RailwaySection()
            {
                StartStation     = sta_B,
                EndStation       = sta_C,
                RailwaySectionID = 2
            });
            #endregion

            #region Generate a timetable
            wor.RailwayTimeTable = new TrainDiagram();
            wor.RailwayTimeTable.Add(new TrainTrip
            {
                Name        = "Train1",
                StopStaions = new List <StopStation>
                {
                    new StopStation()
                    {
                        Station = sta_A,
                        DepTime = new DateTime(1991, 7, 5, 8, 0, 0)
                    },
                    new StopStation()
                    {
                        Station = sta_B,
                        ArrTime = new DateTime(1991, 7, 5, 8, 30, 0),
                        DepTime = new DateTime(1991, 7, 5, 8, 35, 0)
                    },
                    new StopStation()
                    {
                        Station = sta_C,
                        ArrTime = new DateTime(1991, 7, 5, 9, 5, 0)
                    },
                },
                ServiceSegments = new List <ServiceSegment>
                {
                    new ServiceSegment()
                    {
                        DepStation = sta_A,
                        DepTime    = new DateTime(1991, 7, 5, 8, 0, 0),
                        ArrStation = sta_B,
                        ArrTime    = new DateTime(1991, 7, 5, 8, 30, 0)
                    },
                    new ServiceSegment()
                    {
                        DepStation = sta_B,
                        DepTime    = new DateTime(1991, 7, 5, 8, 35, 0),
                        ArrStation = sta_C,
                        ArrTime    = new DateTime(1991, 7, 5, 9, 5, 0)
                    }
                },
                Carriage = new Base.TranResource.TrainCarriage(5)
            });//Train 1
            wor.RailwayTimeTable.Add(new TrainTrip
            {
                Name        = "Train2",
                StopStaions = new List <StopStation>()
                {
                    new StopStation()
                    {
                        Station = sta_A,
                        DepTime = new DateTime(1991, 7, 5, 8, 15, 0)
                    },
                    new StopStation()
                    {
                        Station = sta_B,
                        ArrTime = new DateTime(1991, 7, 5, 8, 55, 0),
                        DepTime = new DateTime(1991, 7, 5, 9, 0, 0)
                    },
                    new StopStation()
                    {
                        Station = sta_C,
                        ArrTime = new DateTime(1991, 7, 5, 9, 40, 0)
                    },
                },
                ServiceSegments = new List <ServiceSegment>
                {
                    new ServiceSegment()
                    {
                        DepStation = sta_A,
                        DepTime    = new DateTime(1991, 7, 5, 8, 15, 0),
                        ArrStation = sta_B,
                        ArrTime    = new DateTime(1991, 7, 5, 8, 55, 0)
                    },
                    new ServiceSegment()
                    {
                        DepStation = sta_B,
                        DepTime    = new DateTime(1991, 7, 5, 9, 0, 0),
                        ArrStation = sta_C,
                        ArrTime    = new DateTime(1991, 7, 5, 9, 40, 0),
                    }
                },
                Carriage = new Base.TranResource.TrainCarriage(5)
            });//Train 2
            #endregion

            #region Generate demand
            wor.Mar = new RailwayMarket()
            {
                AggRo = new List <Interval>()
                {
                    new Interval()
                    {
                        StartDate = new DateTime(1991, 7, 5, 0, 0, 0),
                        StartTime = 0,
                        EndDate   = new DateTime(1991, 7, 5, 0, 10, 10),
                        EndTime   = 10,
                    }
                },
                TimeHorizon = 10
            };
            wor.Mar.ConvertToInttime = x =>
            {
                for (int i = 0; i < wor.Mar.AggRo.Count; i++)
                {
                    if (x >= wor.Mar.AggRo[i].StartDate && x <= wor.Mar.AggRo[i].EndDate)
                    {
                        return(wor.Mar.AggRo[i].StartTime + (int)((wor.Mar.AggRo[i].EndTime - wor.Mar.AggRo[i].StartTime)
                                                                  * (x - wor.Mar.AggRo[i].StartDate).TotalSeconds
                                                                  / (wor.Mar.AggRo[i].EndDate - wor.Mar.AggRo[i].StartDate).TotalSeconds));
                    }
                    ;
                }
                throw new Exception("时间超出范围");
            }; //将刻度时间转化为真实时间
            (wor.Mar as List <RailwayMarketSegment>).AddRange(new List <RailwayMarketSegment>()
            {
                new RailwayMarketSegment
                {
                    MSID        = 1,
                    Description = "A->B",
                    OriSta      = sta_A,
                    DesSta      = sta_B
                },
                new RailwayMarketSegment
                {
                    MSID        = 2,
                    Description = "B->C",
                    OriSta      = sta_B,
                    DesSta      = sta_C
                },
                new RailwayMarketSegment
                {
                    MSID        = 3,
                    Description = "A->C",
                    OriSta      = sta_A,
                    DesSta      = sta_C,
                }
            });
            #endregion

            return(wor);
        }
예제 #7
0
    protected override void OnStart()
    {
        base.OnStart();

        mStation = GetComponent <RailwayStation>();
    }
예제 #8
0
        public void TestInitialize()
        {
            var playersOnSpace = new List <Player>();

            station1 = new RailwayStation(playersOnSpace, "Fenchurch Street", 200, 50, 50, 200);
        }