public static IEnumerable <StudyPlan> TryToImproveSchedule(StudyPlan plan) { // TODO: Fixme Semester first = currentSemester; Semester last = FSharpSchedulingWizard.lastSemester(plan); Semester bestPossible = bestAchievable(plan); //variables for mutating to get the results using while loop IEnumerable <StudyPlan> bestPlans = new StudyPlan[] { }; Semester targetGraduation = StudyPlannerModel.previousSemester(last); while (targetGraduation.CompareTo(bestPossible) >= 0) { IEnumerable <PlannedUnit> bounds = BoundsOptimizer.boundUnitsInPlan(plan, first, targetGraduation); StudyPlan newPlan = scheduleRemaning(bounds, new UnitInPlan[] { }); if (newPlan == null) { break; } //append the newPlan and try to get better plan with tighter target graduation semester bestPlans = bestPlans.Concat(new[] { newPlan }); targetGraduation = StudyPlannerModel.previousSemester(FSharpSchedulingWizard.lastSemester(newPlan)); } return(bestPlans); }
public static IEnumerable <StudyPlan> TryToImproveSchedule(StudyPlan plan) { List <StudyPlan> improvedPlans = new List <StudyPlan>(); // earliest possible sem + first and last sem of study plan Semester earliestPossible = bestPossible(plan, currentSemester); Semester firstSem = currentSemester; /// Semester lastSem = latestSem(plan); // get target completion date Semester target = StudyPlannerModel.previousSemester(lastSem); // /// create new bounds with target completion to be rescheduled into a new study plan List <PlannedUnit> newBound = BoundsOptimizer.boundUnitsInPlan(plan, firstSem, target).ToList(); StudyPlan newPlan; while (target.CompareTo(earliestPossible) >= 0) // while target is still possible { // if bounds infeasible then can't reschedule if (!FSharpSchedulingWizard.allBoundsFeasible(ListModule.OfSeq(newBound))) { return(improvedPlans); /// return sequence } // otherwise, add plan to improved plans newPlan = scheduleRemaining(newBound, new List <UnitInPlan>()); if (newPlan is null) { break; // stop trying to find better plans } improvedPlans.Add(newPlan); // update target semester target = StudyPlannerModel.previousSemester(latestSem(newPlan)); // update new bounds for 1 sem earlier newBound = BoundsOptimizer.boundUnitsInPlan(newPlan, firstSem, target).ToList(); } return(improvedPlans); }