public SemesterViewModel(Semester m) { TypeValue = m.Type; Type = m.Type.ToString(); Year = m.Year; }
/// <summary> /// The writeResults class writes the Course Optimization run to the database. The class takes in the optimization model, all students, all courses, /// all semesters, all course/semster offerings, the dB context, the optimization variable (total slack for overbooked students across all course/ /// semester offerings, and the RunName provided to the Optimization engine. /// </summary> /// <param name="GRBModelData"></param> /// <param name="students"></param> /// <param name="courses"></param> /// <param name="sems"></param> /// <param name="crssems"></param> /// <param name="ctx"></param> /// <param name="ObjectiveValue"></param> /// <param name="RunName"></param> private static void writeResults(GRBVar[,,] GRBModelData, StudentPreference[] students, Course[] courses, Semester[] sems, CourseSemester[] crssems, ApplicationDbContext ctx, int ObjectiveValue, string RunName) { Recommendation rec = new Recommendation() { Name = RunName }; rec.Records = new List<RecommendationRecord>(); rec.StudentPreferences = students; rec.CourseSemesters = crssems; rec.MissingSeats = ObjectiveValue; for (int i = 0; i < students.Length; i++) { for (int j = 0; j < courses.Length; j++) { for (int k = 0; k < sems.Length; k++) { try { if (GRBModelData[i, j, k].Get(GRB.DoubleAttr.X) == 1) rec.Records.Add(new RecommendationRecord() { StudentPreference = students[i], CourseSemester = crssems.Single(m => m.Course == courses[j] && m.Semester == sems[k]) }); } catch (GRBException e) { } } } } ctx.Recommendations.Add(rec); ctx.SaveChanges(); }