//public void GenDataWithCT(double lamada, double transiteRate, double transitUtility) //{ // #region Resource // rs = new ResourceSet(); // Resource r1 = new Resource() // { // ResID = 1, // Description = "Train1:A->B", // Capacity = 5 // }; // Resource r2 = new Resource() // { // ResID = 2, // Description = "Train1:B->C", // Capacity = 5 // }; // Resource r3 = new Resource() // { // ResID = 3, // Description = "Train2:A->B", // Capacity = 5 // }; // Resource r4 = new Resource() // { // ResID = 4, // Description = "Train3:B->C", // Capacity = 5 // }; // //Resource r5 = new Resource() // //{ // // ResID = 5, // // Description = "Train4:A->C", // // Capacity = 10 // //}; // rs.Add(r1); rs.Add(r2); rs.Add(r3); rs.Add(r4);// rs.Add(r5); // #endregion // #region Products // proset = new ProductSet(); // Product pro1 = new Product() { ProID = 1, Description = "Train1:A->B", Fare = 100 }; pro1.Add(r1); // Product pro2 = new Product() { ProID = 2, Description = "Train1:B->C", Fare = 100 }; pro2.Add(r2); // Product pro3 = new Product() { ProID = 3, Description = "Train1:A->C", Fare = 200 }; pro3.Add(r1); pro3.Add(r2); // Product pro4 = new Product() { ProID = 4, Description = "Train2:A->B", Fare = 150 }; pro4.Add(r3); // Product pro5 = new Product() { ProID = 5, Description = "Train3:B->C", Fare = 150 }; pro5.Add(r4); // Product pro6 = new Product() { ProID = 6, Description = "Train2:A->B&Train3:B->C", Fare = 320 }; pro6.Add(r3); pro6.Add(r4); // proset.Add(pro1); proset.Add(pro2); proset.Add(pro3); proset.Add(pro4); proset.Add(pro5); proset.Add(pro6); // #endregion // #region Routes // pathList = new List<Route>(); // //A->B // Route rou1 = new Route(new List<Product>() { pro1 }); // Route rou2 = new Route(new List<Product>() { pro4 }); // //B-C // Route rou3 = new Route(new List<Product>() { pro2 }); // Route rou4 = new Route(new List<Product>() { pro5 }); // //A->C // Route rou5 = new Route(new List<Product>() { pro3 }); // Route rou6 = new Route(new List<Product>() { pro6 });//联程票 // Route rou7 = new Route(new List<Product>() { pro4, pro5 });//换乘 // pathList.Add(rou1); pathList.Add(rou2); pathList.Add(rou3); pathList.Add(rou4); pathList.Add(rou5); pathList.Add(rou6); pathList.Add(rou7); // #endregion // #region Markets // mar = new Market() { Ro = x => { return lamada; } }; // MarketSegment MS1 = new MarketSegment() // { // MSID = 1, // Description = "Price sensitive, Nonstop (A→C)", // Lamada = x => { return 0.5 - transiteRate; }, // Retreat = 0.01 // }; // MS1.ConsiderationDic.Add(rou5, 8); //MS1.ConsiderationDic.Add(rou7, 2); // MarketSegment MS2 = new MarketSegment() // { // MSID = 2, // Description = "Price insensitive, Nonstop (A→C)", // Lamada = x => { return transiteRate; }, // Retreat = 0.01 // }; // MS2.ConsiderationDic.Add(rou5, 8); MS2.ConsiderationDic.Add(rou6, 2 + transitUtility); MS2.ConsiderationDic.Add(rou7, 2); // MarketSegment MS3 = new MarketSegment() // { // MSID = 3, // Description = "A→B", // Lamada = x => { return 0.25; }, // Retreat = 0.01 // }; // MS3.ConsiderationDic.Add(rou1, 4); MS3.ConsiderationDic.Add(rou2, 4); // MarketSegment MS4 = new MarketSegment() // { // MSID = 4, // Description = "B→C", // Lamada = x => { return 0.25; }, // Retreat = 0.01 // }; // MS4.ConsiderationDic.Add(rou3, 4); MS4.ConsiderationDic.Add(rou4, 4); // mar.Add(MS1); mar.Add(MS2); mar.Add(MS3); mar.Add(MS4); // #endregion // this.TimeHorizon = 100; //} //public void GenDataWithoutCT(double lamada, double transiteRate) //{ // #region Resource // rs = new ResourceSet(); // Resource r1 = new Resource() // { // ResID = 1, // Description = "Train1:A->B", // Capacity = 3 // }; // Resource r2 = new Resource() // { // ResID = 2, // Description = "Train1:B->C", // Capacity = 3 // }; // Resource r3 = new Resource() // { // ResID = 3, // Description = "Train2:A->B", // Capacity = 3 // }; // Resource r4 = new Resource() // { // ResID = 4, // Description = "Train3:B->C", // Capacity = 3 // }; // //Resource r5 = new Resource() // //{ // // ResID = 5, // // Description = "Train4:A->C", // // Capacity = 3 // //}; // rs.Add(r1); rs.Add(r2); rs.Add(r3); rs.Add(r4); //rs.Add(r5); // #endregion // #region Products // proset = new ProductSet(); // Product pro1 = new Product() { ProID = 1, Description = "Train1:A->B", Fare = 100 }; pro1.Add(r1); // Product pro2 = new Product() { ProID = 2, Description = "Train1:B->C", Fare = 100 }; pro2.Add(r2); // Product pro3 = new Product() { ProID = 3, Description = "Train1:A->C", Fare = 200 }; pro3.Add(r1); pro3.Add(r2); // Product pro4 = new Product() { ProID = 4, Description = "Train2:A->B", Fare = 150 }; pro4.Add(r3); // Product pro5 = new Product() { ProID = 5, Description = "Train3:B->C", Fare = 150 }; pro5.Add(r4); // //Product pro6 = new Product() { ProID = 6, Description = "Train2:A->B&Train3:B->C", Fare = 320 }; pro6.Add(r3); pro6.Add(r4); // proset.Add(pro1); proset.Add(pro2); proset.Add(pro3); proset.Add(pro4); proset.Add(pro5); //proset.Add(pro6); // #endregion // #region Routes // pathList = new List<Route>(); // //A->B // Route rou1 = new Route(new List<Product>() { pro1 }); // Route rou2 = new Route(new List<Product>() { pro4 }); // //B-C // Route rou3 = new Route(new List<Product>() { pro2 }); // Route rou4 = new Route(new List<Product>() { pro5 }); // //A->C // Route rou5 = new Route(new List<Product>() { pro3 }); // //Route rou6 = new Route(new List<Product>() { pro6 });//联程票 // Route rou7 = new Route(new List<Product>() { pro4, pro5 });//换乘 // pathList.Add(rou1); pathList.Add(rou2); pathList.Add(rou3); pathList.Add(rou4); pathList.Add(rou5); pathList.Add(rou7); // #endregion // #region Markets // mar = new Market() { Ro = x => { return lamada; } }; // MarketSegment MS1 = new MarketSegment() // { // MSID = 1, // Description = "Price sensitive, Nonstop (A→C)", // Lamada = x => { return 0.5 - transiteRate; }, // Retreat = 0.001 // }; // MS1.ConsiderationDic.Add(rou5, 8); //MS1.ConsiderationDic.Add(rou7, 2); // MarketSegment MS2 = new MarketSegment() // { // MSID = 2, // Description = "Price insensitive, Nonstop (A→C)", // Lamada = x => { return transiteRate; }, // Retreat = 0.001 // }; // MS2.ConsiderationDic.Add(rou5, 8); MS2.ConsiderationDic.Add(rou7, 2); // MarketSegment MS3 = new MarketSegment() // { // MSID = 3, // Description = "A→B", // Lamada = x => { return 0.25; }, // Retreat = 0.001 // }; // MS3.ConsiderationDic.Add(rou1, 4); MS3.ConsiderationDic.Add(rou2, 4); // MarketSegment MS4 = new MarketSegment() // { // MSID = 4, // Description = "B→C", // Lamada = x => { return 0.25; }, // Retreat = 0.001 // }; // MS4.ConsiderationDic.Add(rou3, 4); MS4.ConsiderationDic.Add(rou4, 4); // mar.Add(MS1); mar.Add(MS2); mar.Add(MS3); mar.Add(MS4); // #endregion //} public void GenTimetable() { tt = new Timetable(); DataTable index = _ds.Tables["Train"]; DataTable detail = _ds.Tables["TimeTable"]; foreach (DataRow dr in index.Rows) { Train t = new Train() { Name = dr["ID"].ToString(), PriceRatio = Convert.ToDouble(dr["PriceRatio"]), Cap = Convert.ToInt32(dr["Capacity"]) }; //Initialize the station list. foreach (DataRow dr2 in detail.Rows) { if (t.Name == dr2["ID"].ToString()) { t.StaList.Add(new StopStation(t) { StationName = dr2["Station"].ToString(), ArrTime = new DateTime(1, 1, 1, Convert.ToInt32(dr2["ArrTime_H"]), Convert.ToInt32(dr2["ArrTime_M"]), 0), DepTime = new DateTime(1, 1, 1, Convert.ToInt32(dr2["Deptime_H"]), Convert.ToInt32(dr2["Deptime_M"]), 0), MileStone = Convert.ToDouble(dr2["MileStone"]) }); } } //Initialize the section list. t.GenSecList(); tt.Add(t); } }
public Transport(Driver driver, List <DateTime> timetable, int amount, int stock) { this.TransportDriver = driver; this.Amount = amount; this.Stock = stock; int index = 0; foreach (DateTime item in timetable) { Timetable.Add(++index, item); } }
public void It_should_be_able_to_get_a_sequence_position_from_the_stop_sequence_controls() { var timetable = new Timetable(Tempo.FromBPM(120)); timetable.Add(BeatPoint.At(4, 0, 1), Tempo.FromBPM(-60), BeatDuration.One); timetable.Add(BeatPoint.At(6, 0, 1), Tempo.FromBPM(30), BeatDuration.One); timetable.Add(BeatPoint.At(7, 0, 1), Tempo.FromBPM(-15), BeatDuration.One); Assert.That( timetable.GetSequencePositionAt(TimePoint.Zero), Is.EqualTo(BeatPointFloat.Zero), "Invalid at 0.0 sec." ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(0.25f)), Is.EqualTo(BeatPointFloat.At(0.5f)), "Invalid at 0.25 sec" ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(2.0f)), Is.EqualTo(BeatPointFloat.At(4.0f)), "Invalid at 2.0 sec" ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(4.0f)), Is.EqualTo(BeatPointFloat.At(3.0f)), "Invalid at 4.0 sec" ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(8.5f)), Is.EqualTo(BeatPointFloat.At(2.75f)), "Invalid at 8.5 sec" ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(12.0f)), Is.EqualTo(BeatPointFloat.At(3.0f)), "Invalid at 12.0 sec" ); }
public void It_should_be_able_to_get_a_time_point_from_only_the_positive_tempo_controls() { var timetable = new Timetable(Tempo.FromBPM(120)); timetable.Add(BeatPoint.At(4, 0, 1), Tempo.FromBPM(60)); timetable.Add(BeatPoint.At(6, 0, 1), Tempo.FromBPM(30)); timetable.Add(BeatPoint.At(7, 0, 1), Tempo.FromBPM(15)); Assert.That( timetable.GetTimeAt(BeatPoint.Zero), Is.EqualTo(TimePoint.Zero), "Invalid at 0.0 beats." ); Assert.That( timetable.GetTimeAt(BeatPoint.At(0, 1, 2)), Is.EqualTo(TimePoint.AtSeconds(0.25f)), "Invalid at 0.5 beats" ); Assert.That( timetable.GetTimeAt(BeatPoint.At(4, 0, 1)), Is.EqualTo(TimePoint.AtSeconds(2.0f)), "Invalid at 4.0 beats" ); Assert.That( timetable.GetTimeAt(BeatPoint.At(5, 0, 1)), Is.EqualTo(TimePoint.AtSeconds(3.0f)), "Invalid at 5.0 beats" ); Assert.That( timetable.GetTimeAt(BeatPoint.At(6, 3, 4)), Is.EqualTo(TimePoint.AtSeconds(5.5f)), "Invalid at 6.75 beats" ); Assert.That( timetable.GetTimeAt(BeatPoint.At(8, 0, 1)), Is.EqualTo(TimePoint.AtSeconds(10.0f)), "Invalid at 8.0 beats" ); }
public void It_should_be_able_to_get_a_time_point_from_the_stop_sequence_controls() { var timetable = new Timetable(Tempo.FromBPM(120)); timetable.Add(BeatPoint.At(4, 0, 1), Tempo.FromBPM(-60), BeatDuration.One); timetable.Add(BeatPoint.At(6, 0, 1), Tempo.FromBPM(30), BeatDuration.One); timetable.Add(BeatPoint.At(7, 0, 1), Tempo.FromBPM(-15), BeatDuration.One); Assert.That( timetable.GetTimeAt(BeatPoint.Zero), Is.EqualTo(TimePoint.Zero), "Invalid at 0.0 beats." ); Assert.That( timetable.GetTimeAt(BeatPoint.At(0, 1, 2)), Is.EqualTo(TimePoint.AtSeconds(0.25f)), "Invalid at 0.5 beats" ); Assert.That( timetable.GetTimeAt(BeatPoint.At(4, 0, 1)), Is.EqualTo(TimePoint.AtSeconds(2.0f)), "Invalid at 4.0 beats" ); Assert.That( timetable.GetTimeAt(BeatPoint.At(5, 0, 1)), Is.EqualTo(TimePoint.AtSeconds(4.0f)), "Invalid at 5.0 beats" ); Assert.That( timetable.GetTimeAt(BeatPoint.At(6, 3, 4)), Is.EqualTo(TimePoint.AtSeconds(8.5f)), "Invalid at 6.75 beats" ); Assert.That( timetable.GetTimeAt(BeatPoint.At(8, 0, 1)), Is.EqualTo(TimePoint.AtSeconds(17.0f)), "Invalid at 8.0 beats" ); }
public void It_should_be_able_to_get_a_beat_count_from_the_reversed_tempo_controls() { var timetable = new Timetable(Tempo.FromBPM(120)); timetable.Add(BeatPoint.At(4, 0, 1), Tempo.FromBPM(-60)); timetable.Add(BeatPoint.At(6, 0, 1), Tempo.FromBPM(30)); timetable.Add(BeatPoint.At(7, 0, 1), Tempo.FromBPM(-15)); Assert.That( timetable.GetBeatTimeAt(TimePoint.Zero), Is.EqualTo(BeatPointFloat.Zero), "Invalid at 0.0 sec." ); Assert.That( timetable.GetBeatTimeAt(TimePoint.AtSeconds(0.25f)), Is.EqualTo(BeatPointFloat.At(0.5f)), "Invalid at 0.25 sec" ); Assert.That( timetable.GetBeatTimeAt(TimePoint.AtSeconds(2.0f)), Is.EqualTo(BeatPointFloat.At(4.0f)), "Invalid at 2.0 sec" ); Assert.That( timetable.GetBeatTimeAt(TimePoint.AtSeconds(3.0f)), Is.EqualTo(BeatPointFloat.At(5.0f)), "Invalid at 3.0 sec" ); Assert.That( timetable.GetBeatTimeAt(TimePoint.AtSeconds(5.5f)), Is.EqualTo(BeatPointFloat.At(6.75f)), "Invalid at 5.5 sec" ); Assert.That( timetable.GetBeatTimeAt(TimePoint.AtSeconds(10.0f)), Is.EqualTo(BeatPointFloat.At(8.0f)), "Invalid at 10.0 sec" ); }
public void It_should_be_able_to_get_a_sequence_position_from_only_the_positive_tempo_controls() { var timetable = new Timetable(Tempo.FromBPM(120)); timetable.Add(BeatPoint.At(4, 0, 1), Tempo.FromBPM(60)); timetable.Add(BeatPoint.At(6, 0, 1), Tempo.FromBPM(30)); timetable.Add(BeatPoint.At(7, 0, 1), Tempo.FromBPM(15)); Assert.That( timetable.GetSequencePositionAt(TimePoint.Zero), Is.EqualTo(BeatPointFloat.Zero), "Invalid at 0.0 sec." ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(0.25f)), Is.EqualTo(BeatPointFloat.At(0.5f)), "Invalid at 0.25 sec" ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(2.0f)), Is.EqualTo(BeatPointFloat.At(4.0f)), "Invalid at 2.0 sec" ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(3.0f)), Is.EqualTo(BeatPointFloat.At(5.0f)), "Invalid at 3.0 sec" ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(5.5f)), Is.EqualTo(BeatPointFloat.At(6.75f)), "Invalid at 4.75 sec" ); Assert.That( timetable.GetSequencePositionAt(TimePoint.AtSeconds(10.0f)), Is.EqualTo(BeatPointFloat.At(8.0f)), "Invalid at 10.0 sec" ); }
private void FilterTimetable() { TimetableCourseProject Context = new TimetableCourseProject(); TimetableDatabase = new ObservableCollection <Timetable>(Context.Timetable.ToList()); if (Timetable != null) { Timetable.Clear(); if (TimetableDatabase.Count != 0) { foreach (var obj in TimetableDatabase) { if (FilterTimetable(obj)) { Timetable.Add(obj); } } } } }
private bool ReadTasksList() { bool result = false; TasksLists = new Timetable(); XmlNode tasks = GetDocumentNode("Tasks"); if (tasks != null && tasks.HasChildNodes) { foreach (XmlNode taskXml in tasks.ChildNodes) { Job t; string taskName = ParseTask(taskXml, out t); Timetable.Entry entry = new Timetable.Entry(); entry.Task = t; TasksLists.Add(entry); } } return(result); }
public static Timetable CreateTimetable() { var timetable = new Timetable("Test", Layout()); timetable.Add(CreateTrain1()); timetable.Add(CreateTrain2()); return timetable; }
// exposes access to remote objects public static async Task <Timetable> getRemoteTimetable() { Debug.WriteLine("[getRemoteTimetable] start"); await login(); var ticket = await POST( "http://learn.cic.tsinghua.edu.cn:80/gnt", "appId=ALL_ZHJW"); //await 十1s(); //cross-domain tickets needs some time to take effect bool outside_campus_network = false; try { var zhjw = await GET( $"http://zhjw.cic.tsinghua.edu.cn/j_acegi_login.do?url=/&ticket={ticket}"); } catch (System.Runtime.InteropServices.COMException e) { if (e.Message.IndexOf("403") == -1) { throw e; } Debug.WriteLine("[getRemoteTimetable] outside campus network"); //throw new NeedCampusNetworkException(); outside_campus_network = true; } if (outside_campus_network) { //connect via sslvpn await logoutSSLVPN(); await loginSSLVPN(); await login(); ticket = await POST( "http://learn.cic.tsinghua.edu.cn:80/gnt", "appId=ALL_ZHJW"); await 十1s(); var ticketPage = await GET( $"https://sslvpn.tsinghua.edu.cn/,DanaInfo=zhjw.cic.tsinghua.edu.cn+j_acegi_login.do?url=/&ticket={ticket}"); Timetable timetable = new Timetable(); for (int i = -6; i <= 4; i += 2) { string page; try { page = await get_calendar_sslvpn_page( DateTime.Now.AddMonths(i).AddDays(1).ToString("yyyyMMdd"), DateTime.Now.AddMonths(i + 2).ToString("yyyyMMdd") ); } catch (Exception) { page = await get_calendar_sslvpn_page( DateTime.Now.AddMonths(i).AddDays(1).ToString("yyyyMMdd"), DateTime.Now.AddMonths(i + 2).ToString("yyyyMMdd") ); } var set_to_be_appended = parseTimetablePage(page); foreach (var _____ in set_to_be_appended) { timetable.Add(_____); } } logoutSSLVPN(); Debug.WriteLine("[getRemoteTimetable] returning sslvpn"); return(timetable); } else { //TODO: duplicate code //connect directly Timetable timetable = new Timetable(); for (int i = -6; i <= 4; i += 2) { string page; try { page = await get_calendar_page( DateTime.Now.AddMonths(i).AddDays(1).ToString("yyyyMMdd"), DateTime.Now.AddMonths(i + 2).ToString("yyyyMMdd") ); } catch (Exception) { page = await get_calendar_page( DateTime.Now.AddMonths(i).AddDays(1).ToString("yyyyMMdd"), DateTime.Now.AddMonths(i + 2).ToString("yyyyMMdd") ); } var set_to_be_appended = parseTimetablePage(page); foreach (var _____ in set_to_be_appended) { timetable.Add(_____); } } Debug.WriteLine("[getRemoteTimetable] returning direct"); return(timetable); } }
public static async Task <Timetable> getTimetable(bool forceRemote = false) { if (isDemo()) { var table = new Timetable(); var start = DateTime.Now.AddDays(-20); while (start.DayOfWeek != DayOfWeek.Monday) { start = start.AddDays(-1); } for (var i = 0; i < 10; i++) { table.Add(new Event { nr = "形式语言与自动机", dd = "六教 6A301", nq = start.AddDays(i * 7 + 2).ToString("yyyy-MM-dd"), kssj = "08:00", jssj = "09:35" }); table.Add(new Event { nr = "高级数据结构", dd = "六教 6A301", nq = start.AddDays(i * 7 + 2).ToString("yyyy-MM-dd"), kssj = "09:50", jssj = "11:25" }); table.Add(new Event { nr = "操作系统", dd = "六教 6A303", nq = start.AddDays(i * 7 + 3).ToString("yyyy-MM-dd"), kssj = "09:50", jssj = "11:25" }); table.Add(new Event { nr = "概率论与数理统计", dd = "六教 6C102", nq = start.AddDays(i * 7 + 4).ToString("yyyy-MM-dd"), kssj = "15:20", jssj = "16:55" }); table.Add(new Event { nr = "概率论与数理统计", dd = "一教 104", nq = start.AddDays(i * 7 + 1).ToString("yyyy-MM-dd"), kssj = "13:30", jssj = "15:05" }); } return(table); } //fetch from remote var _remoteTimetable = await Remote.getRemoteTimetable(); Debug.WriteLine("[getTimetable] Returning remote"); return(_remoteTimetable); }
Timetable ITimetableRepository.GetTimetable(string name) { var result = new Timetable(name, GetLayout()); result.Add(TestDataFactory.CreateTrain1()); result.Add(TestDataFactory.CreateTrain2()); return result; }