コード例 #1
0
    def testTwoOptions(self):
        courses = create_minimal_course_list(4.0)
        result = co.optimize(courses)
        self.assertTrue(result.possible)
        self.assertAlmostEquals(result.max_grade, 4.0)

        better_courses = [
            co.Course("Better core focus", 6.0, 24, co.Category.CORE_FOCUS,
                      co.Category.ELECTIVE, co.Category.ELECTIVE_CS,
                      co.Category.ELECTIVE),
            co.Course("Better seminar", 6.0, 2, co.Category.SEMINAR_IN_FOCUS),
            co.Course("Better elective", 6.0, 10, co.Category.ELECTIVE_CS,
                      co.Category.ELECTIVE),
            co.Course("Better interfocus", 6.0, 12, co.Category.INTERFOCUS),
            co.Course("Better gess", 6.0, 2,
                      co.Category.SCIENCE_IN_PERSPECTIVE),
        ]
        expected_grades = [
            (3 * (6 * 24 + 4 * 2) / 26 + 4 + 4 + 2 * 4) / 7,
            (3 * (4 * 24 + 6 * 2) / 26 + 4 + 4 + 2 * 4) / 7,
            (3 * 4 + 6 + 4 + 2 * 4) / 7,
            (3 * 4 + 4 + 6 + 2 * 4) / 7,
            (3 * 4 + 4 + 4 + 2 * 4) / 7,  # gess has no effect
        ]

        for better_course, expected_grade in zip(better_courses,
                                                 expected_grades):
            better_result = co.optimize(courses + [better_course])
            self.assertTrue(better_result.possible)
            self.assertAlmostEquals(better_result.max_grade, expected_grade)
コード例 #2
0
    def testInsufficientFocusCredits(self):
        courses = create_minimal_course_list(4.0)
        courses = [
            course for course in courses
            if co.Category.CORE_FOCUS not in course._categories
        ]
        courses.append(co.Course("asdf", 4.0, 23, co.Category.CORE_FOCUS))
        result = co.optimize(courses)

        self.assertFalse(result.possible)
        courses.append(co.Course("qwerty", 4.0, 1, co.Category.ELECTIVE_FOCUS))
        result = co.optimize(courses)
        self.assertTrue(result.possible)
        self.assertAlmostEquals(result.max_grade, 4.0)
コード例 #3
0
    def testWhenBetterToRedistribute(self):
        courses = create_minimal_course_list(4.0)
        result = co.optimize(courses)
        self.assertTrue(result.possible)
        self.assertAlmostEquals(result.max_grade, 4.0)

        # in this case, it's better to count one core focus as the main core focus, and use the other to replace
        # elective cs
        bcf1 = co.Course("Better core focus 1", 6.0, 24,
                         co.Category.CORE_FOCUS, co.Category.ELECTIVE,
                         co.Category.ELECTIVE_CS, co.Category.ELECTIVE)
        bcf2 = co.Course("Better core focus 2", 6.0, 24,
                         co.Category.CORE_FOCUS, co.Category.ELECTIVE,
                         co.Category.ELECTIVE_CS, co.Category.ELECTIVE)

        better_result = co.optimize(courses + [bcf1, bcf2])
        self.assertTrue(better_result.possible)
        self.assertGreater(better_result.max_grade, result.max_grade)
        self.assertAlmostEquals(better_result.max_grade,
                                (3 *
                                 (6 * 24 + 4 * 2) / 26 + 6 + 4 + 2 * 4) / 7)
コード例 #4
0
 def testCantUseTwoLabs(self):
     default_grade = 4.0
     courses = [
         co.Course("CF", default_grade, 24, co.Category.CORE_FOCUS,
                   co.Category.ELECTIVE, co.Category.ELECTIVE_CS,
                   co.Category.ELECTIVE),
         co.Course("SF", default_grade, 2, co.Category.SEMINAR_IN_FOCUS),
         co.Course("ECS1", default_grade, 10,
                   co.Category.ELECTIVE_CS).lab(True),
         co.Course("ECS2", default_grade, 10, co.Category.ELECTIVE_CS,
                   co.Category.ELECTIVE).lab(True),
         co.Course("IF", default_grade, 12, co.Category.INTERFOCUS),
         co.Course("SIP", default_grade, 2,
                   co.Category.SCIENCE_IN_PERSPECTIVE),
         co.Course("MT", default_grade, 30, co.Category.THESIS),
     ]
     result = co.optimize(courses)
     self.assertFalse(result.possible)
コード例 #5
0
 def testInsufficientTotalCredits(self):
     default_grade = 4.0
     courses = [
         co.Course("CF", default_grade, 24, co.Category.CORE_FOCUS,
                   co.Category.ELECTIVE, co.Category.ELECTIVE_CS,
                   co.Category.ELECTIVE),
         co.Course("SF", default_grade, 2, co.Category.SEMINAR_IN_FOCUS),
         co.Course("ECS", default_grade, 10, co.Category.ELECTIVE_CS,
                   co.Category.ELECTIVE),
         co.Course("IF", default_grade, 12, co.Category.INTERFOCUS),
         co.Course("EL", default_grade, 9, co.Category.ELECTIVE),
         co.Course("SIP", default_grade, 2,
                   co.Category.SCIENCE_IN_PERSPECTIVE),
         co.Course("MT", default_grade, 30, co.Category.THESIS),
     ]
     result = co.optimize(courses)
     self.assertFalse(result.possible)
     courses.append(co.Course("EL2", default_grade, 1,
                              co.Category.ELECTIVE))
     result = co.optimize(courses)
     self.assertTrue(result.possible)
     self.assertAlmostEquals(result.max_grade, 4.0)
コード例 #6
0
def create_minimal_course_list(default_grade=5.0):
    courses = [
        co.Course("Intro to FizzBuzz", default_grade, 24,
                  co.Category.CORE_FOCUS, co.Category.ELECTIVE,
                  co.Category.ELECTIVE_CS, co.Category.ELECTIVE),
        co.Course("Advanced methods in FizzBuzzing", default_grade, 2,
                  co.Category.SEMINAR_IN_FOCUS),
        co.Course("Information security: Fuzzing Busily", default_grade, 10,
                  co.Category.ELECTIVE_CS, co.Category.ELECTIVE),
        co.Course("Advanced computational algorithms lab", default_grade, 12,
                  co.Category.INTERFOCUS),
        co.Course("Intro to Buzzsaws?", default_grade, 10,
                  co.Category.ELECTIVE),
        co.Course("FizzBuzz and society", default_grade, 2,
                  co.Category.SCIENCE_IN_PERSPECTIVE),
        co.Course("Buzzing and Fizzing: What's next?", default_grade, 30,
                  co.Category.THESIS),
    ]
    return courses
コード例 #7
0
def main():
    # Some general notes:
    # -Only one (non-interfocus) lab course can be counted. The optimization takes this into account, so label all your
    #  non-interfocus lab courses as such.
    # -Most courses that count as "Core Focus" or "Elective Focus" can also count for "Elective CS" or just "Elective",
    #  so label all your focus courses as electives, too
    # -On the other hand, most seminar courses can only count as a "Seminar in Focus". It's not really stated
    #  explicitly, but the department doesn't like it when you get a lot of seminar credits. So don't label those as
    #  electives.
    # -If you're a m*******t and take all 3 interfocus labs, I'm not sure if you can count one as an elective or not.
    courses = [
        co.Course("FNC", 5.25, 6, co.Category.CORE_FOCUS,
                  co.Category.ELECTIVE_FOCUS),
        co.Course("ML", 5.5, 8, co.Category.CORE_FOCUS,
                  co.Category.ELECTIVE_CS),
        co.Course("DM", 5.25, 4, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE_FOCUS),
        co.Course("IR", 5.25, 4, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE_FOCUS),
        co.Course("Prob AI", 5.0, 4, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE_FOCUS),
        co.Course("ML Seminar", 5.5, 2, co.Category.SEMINAR_IN_FOCUS),
        co.Course("Comp Stats", 5., 10, co.Category.ELECTIVE_CS),
        co.Course("NLU", 5.5, 4, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE_FOCUS),
        co.Course("RiCS", 6, 5, co.Category.ELECTIVE_CS),
        co.Course("ASL", 5, 8, co.Category.INTERFOCUS),
        co.Course("CIL", 5.25, 6, co.Category.INTERFOCUS),
        co.Course("SciFi", 6, 2, co.Category.SCIENCE_IN_PERSPECTIVE),
        co.Course("thesis", 5, 30, co.Category.THESIS), # worst case
    ]

    print('=========================================')
    print('Considering the following courses:')
    for c in courses:
        print('\t', c)
    print('=========================================')
    print('Optimizing!')
    start = time.time()
    result = co.optimize(courses)
    end = time.time()
    print('... complete! Optimization took', (end - start), 'seconds.')
    print('=========================================')

    if not result.possible:
        print('It looks like you don\'t have enough credits to graduate! :(')
        print(
            'Have you entered ALL your passed courses? This includes your thesis, GESS courses, and elective courses.'
        )
    else:

        categories_to_names = OrderedDict()
        categories_to_names[co.Category.CORE_FOCUS] = "Core Focus"
        categories_to_names[co.Category.ELECTIVE_FOCUS] = "Elective Focus"
        categories_to_names[co.Category.SEMINAR_IN_FOCUS] = "Seminar in Focus"
        categories_to_names[co.Category.ELECTIVE_CS] = "Elective CS"
        categories_to_names[co.Category.INTERFOCUS] = "Interfocus"
        categories_to_names[co.Category.ELECTIVE] = "Elective"
        categories_to_names[
            co.Category.
            SCIENCE_IN_PERSPECTIVE] = "Science in Perspective (GESS)"
        categories_to_names[co.Category.THESIS] = "Master Thesis"

        print('Your best course assignments give a grade of', result.max_grade)
        print('(The worst grade encountered was', result.worst_grade, ')')
        print('Assign your courses to categories in the following way:')
        print('=========================================')
        for category, name in categories_to_names.items():
            course_list = result.assignments[category]
            print(name)
            if len(course_list) == 0:
                print('\t(none)')
            else:
                for course in course_list:
                    print('\t', course)
                    courses.remove(course)
        if len(courses) > 0:
            print(
                'Mark these courses as "Performance Assessments without Category":'
            )
            for course in courses:
                print('\t', course)
    print('\nHave a nice day.')
コード例 #8
0
def main():
    # Some general notes:
    # -Only one (non-interfocus) lab course can be counted. The optimization takes this into account, so label all your
    #  non-interfocus lab courses as such.
    # -Most courses that count as "Core Focus" or "Elective Focus" can also count for "Elective CS" or just "Elective",
    #  so label all your focus courses as electives, too
    # -On the other hand, most seminar courses can only count as a "Seminar in Focus". It's not really stated
    #  explicitly, but the department doesn't like it when you get a lot of seminar credits. So don't label those as
    #  electives.
    # -If you're a m*******t and take all 3 interfocus labs, I'm not sure if you can count one as an elective or not.
    courses = [
        co.Course("Intro to FizzBuzz", 4.75, 8, co.Category.CORE_FOCUS,
                  co.Category.ELECTIVE, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE),
        co.Course("How to Design Manhole Covers", 4.0, 6,
                  co.Category.CORE_FOCUS, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE),
        co.Course("Twiddling Your Thumbs I", 5.25, 6,
                  co.Category.ELECTIVE_FOCUS, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE),
        co.Course("Twiddling Your Thumbs II", 5.5, 6,
                  co.Category.ELECTIVE_FOCUS, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE),
        co.Course("Advanced methods in FizzBuzzing", 5.25, 2,
                  co.Category.SEMINAR_IN_FOCUS),
        co.Course("Information security Lab: Fuzzing Busily", 5.0, 10,
                  co.Category.ELECTIVE_CS, co.Category.ELECTIVE).lab(True),
        co.Course("P = NP, Just Set N=1", 4.25, 4, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE),
        co.Course("Support Vector Machine Guns", 4.75, 4,
                  co.Category.ELECTIVE_CS, co.Category.ELECTIVE),
        co.Course("The Pass/Fail Course", None, 10, co.Category.ELECTIVE_CS,
                  co.Category.ELECTIVE).passfail(True),
        co.Course("Advanced computational algorithms lab", 4.0, 12,
                  co.Category.INTERFOCUS),
        co.Course("Intro to Buzzsaws", 6.0, 8, co.Category.ELECTIVE),
        co.Course("Critical Analysis of the Bee Movie", 4.5, 6,
                  co.Category.ELECTIVE),
        co.Course("FizzBuzz and society", 4.5, 2,
                  co.Category.SCIENCE_IN_PERSPECTIVE),
        co.Course("Buzzing and Fizzing: What's next?", 5.5, 30,
                  co.Category.THESIS),
    ]

    print('=========================================')
    print('Considering the following courses:')
    for c in courses:
        print('\t', c)
    print('=========================================')
    print('Optimizing!')
    start = time.time()
    result = co.optimize(courses)
    end = time.time()
    print('... complete! Optimization took', (end - start), 'seconds.')
    print('=========================================')

    if not result.possible:
        print('It looks like you don\'t have enough credits to graduate! :(')
        print(
            'Have you entered ALL your passed courses? This includes your thesis, GESS courses, and elective courses.'
        )
    else:

        categories_to_names = OrderedDict()
        categories_to_names[co.Category.CORE_FOCUS] = "Core Focus"
        categories_to_names[co.Category.ELECTIVE_FOCUS] = "Elective Focus"
        categories_to_names[co.Category.SEMINAR_IN_FOCUS] = "Seminar in Focus"
        categories_to_names[co.Category.ELECTIVE_CS] = "Elective CS"
        categories_to_names[co.Category.INTERFOCUS] = "Interfocus"
        categories_to_names[co.Category.ELECTIVE] = "Elective"
        categories_to_names[
            co.Category.
            SCIENCE_IN_PERSPECTIVE] = "Science in Perspective (GESS)"
        categories_to_names[co.Category.THESIS] = "Master Thesis"

        print('Your best course assignments give a grade of', result.max_grade)
        print('(The worst grade encountered was', result.worst_grade, ')')
        print('Assign your courses to categories in the following way:')
        print('=========================================')
        for category, name in categories_to_names.items():
            course_list = result.assignments[category]
            print(name)
            if len(course_list) == 0:
                print('\t(none)')
            else:
                for course in course_list:
                    print('\t', course)
                    courses.remove(course)
        if len(courses) > 0:
            print(
                'Mark these courses as "Performance Assessments without Category":'
            )
            for course in courses:
                print('\t', course)
    print('\nHave a nice day.')