//------------------------------------------------------------------------------ // Order in which the scheduler processes the jobs is not fixed in advance // Of course, we have prerequisites so not everything can be scheduled at random // so what we do is define the leaves (stuff we can parallelize) and try to find the best // path for those. //------------------------------------------------------------------------------ public Schedule CreateSchedule(bool preferShortest) { List <Job> majorCourses = RequiredCourses.GetList(0); //Find the major courses with the longest prereq network. How to find it? Basically, create a new sortedList //for each major course separately and process them one at a time. var prereqLists = new List <SortedDictionary <int, List <Job> > >(); for (int i = 0; i < majorCourses.Count; i++) { var sortedPrereqs = new SortedDictionary <int, List <Job> >(); Job job = majorCourses[i]; AddPrerequisites(job, sortedPrereqs, preferShortest, 0); prereqLists.Add(sortedPrereqs); } //now, sort the prereqsList based on the longest path var prereqLongest = prereqLists.OrderByDescending(s => s.Count); foreach (SortedDictionary <int, List <Job> > prereqSeq in prereqLongest) { ScheduleCourses(prereqSeq); } Schedule = GetBusyMachines(); return(new Schedule() { Courses = this.Schedule, SchedulerName = nameof(LongestPathScheduler) }); }
//------------------------------------------------------------------------------ // Order in which the scheduler processes the jobs is not fixed in advance // Of course, we have prerequisites so not everything can be scheduled at random // so what we do is define the leaves (stuff we can parallelize) and try to find the best // path for those. //------------------------------------------------------------------------------ public Schedule CreateSchedule(bool preferShortest) { List <Job> majorCourses = RequiredCourses.GetList(0); SortedDictionary <int, List <Job> > jobs = new SortedDictionary <int, List <Job> >(); for (int i = 0; i < majorCourses.Count; i++) { Job job = majorCourses[i]; AddPrerequisites(job, jobs, preferShortest, 0); } return(FindBestSchedule(jobs, 4, 100, 25, this.CurrentBestFit)); }
//------------------------------------------------------------------------------ // Order in which the scheduler processes the jobs is not fixed in advance // Of course, we have prerequisites so not everything can be scheduled at random // so what we do is define the leaves (stuff we can parallelize) and try to find the best // path for those. //------------------------------------------------------------------------------ public Schedule CreateSchedule(bool preferShortest) { List <Job> majorCourses = RequiredCourses.GetList(0); SortedDictionary <int, List <Job> > jobs = new SortedDictionary <int, List <Job> >(); for (int i = 0; i < majorCourses.Count; i++) { Job job = majorCourses[i]; AddPrerequisites(job, jobs, preferShortest, 0); } ScheduleCourses(jobs); Schedule = GetBusyMachines(); //SUGGEST BETTER NAMING CONVENTION?// //return proposed schedule return(new Schedule() { Courses = this.Schedule, SchedulerName = nameof(OpenShopScheduler) }); }