public void TestMathBreaksFromDataBase() { const int GENERATED_PLAN_ID = 933; // Contains breaks in the math sequence const int PARAMETER_SET_ID = 213; ScheduleModel sm = getScheduleFromDB(GENERATED_PLAN_ID); // Replace the int here with the actual schedule ID Evaluator eval = new Evaluator(); // Construct a preference set. Preferences pref = GetPreferencesFromDB(PARAMETER_SET_ID); // Replace the int here with an actual preference set ID // Associate the schedule with a given preference set: sm.PreferenceSet = pref; Criteria mb = new MathBreaks(2.0); double result = mb.getResult(sm); Assert.AreEqual(result, 0.0); }
public void TestMathBreaksInvalidSchedule() { const int MATH_DEPT = 54; ScheduleModel sm = new ScheduleModel { Quarters = new List <Quarter> { new Quarter { Id = "1", Courses = new List <Course> { new Course { DepartmentID = MATH_DEPT } } }, new Quarter { Id = "2", Courses = new List <Course> { new Course { DepartmentID = MATH_DEPT + 1 } } }, new Quarter { Id = "3", Courses = new List <Course> { new Course { DepartmentID = MATH_DEPT } } }, new Quarter { Id = "4", Courses = new List <Course> { new Course { DepartmentID = MATH_DEPT + 1 } } }, } }; Criteria mb = new MathBreaks(1.0); double result = mb.getResult(sm); Assert.AreEqual(0.0, result); }
public CriteriaFactory(CritTyp[] types, double[] weights) { // Check to make sure the paramaters are legal. if (types.Length != weights.Length) { throw new ArgumentException("Must have equal number of weights and types"); } if (types.Length == 0 || types.Length == 0) { throw new ArgumentException("Criteria Types and Weights must have elements"); } // This is preliminary weight validation. This should be implemented lated to follow the actual rules that // we want. //double sum = 0; //foreach (double val in weights) // sum += val; //if (sum != 1.0) // throw new ArgumentException("Weights must sum to 1.0"); Criterias = new Criteria[types.Length]; for (int i = 0; i < types.Length; i++) { CritTyp ct = types[i]; double w = weights[i]; if (ct == CritTyp.AllPrereqs) { Criterias[i] = new AllPrereqs(w); } else if (ct == CritTyp.CoreClassesLastYear) { Criterias[i] = new CoreClassesLastYear(w); } else if (ct == CritTyp.CoreCreditsAQuarter) { Criterias[i] = new CoreCreditsAQuarter(w); } else if (ct == CritTyp.ElectiveRelevancy) { Criterias[i] = new ElectiveRelevancy(w); } else if (ct == CritTyp.EnglishStart) { Criterias[i] = new EnglishStart(w); } else if (ct == CritTyp.MajorSpecificBreaks) { Criterias[i] = new MajorSpecificBreaks(w); } else if (ct == CritTyp.MathBreaks) { Criterias[i] = new MathBreaks(w); } else if (ct == CritTyp.MaxQuarters) { Criterias[i] = new MaxQuarters(w); } else if (ct == CritTyp.PreRequisiteOrder) { Criterias[i] = new PreRequisiteOrder(w); } else if (ct == CritTyp.TimeOfDay) { Criterias[i] = new TimeOfDay(w); } else if (ct == CritTyp.EnglishClassStart) { Criterias[i] = new EnglishClassStart(w); } else { throw new ArgumentException("Illegal Criteria Type"); } } }