예제 #1
0
파일: grader.py 프로젝트: jhmuller/XCS221
 def test_3(self):
     """3b-3-hidden:  Test MVC+AC-3+all additional constraints"""
     profile = util.Profile(bulletin, 'profile3b3.txt')
     cspConstructor = submission.SchedulingCSPConstructor(
         bulletin, copy.deepcopy(profile))
     csp = cspConstructor.get_basic_csp()
     cspConstructor.add_all_additional_constraints(csp)
     alg = submission.BacktrackingSearch()
     alg.solve(csp, mcv=True, ac3=True)
예제 #2
0
파일: grader.py 프로젝트: jhmuller/XCS221
 def test_2(self):
     """3b-2-hidden:  Test unsatisfiable scheduling"""
     profile = util.Profile(bulletin, 'profile3b2.txt')
     cspConstructor = submission.SchedulingCSPConstructor(
         bulletin, copy.deepcopy(profile))
     csp = cspConstructor.get_basic_csp()
     cspConstructor.add_all_additional_constraints(csp)
     alg = submission.BacktrackingSearch()
     alg.solve(csp)
예제 #3
0
파일: grader.py 프로젝트: jhmuller/XCS221
 def test_1(self):
     """3b-1-hidden:  Test add_unit_constraints with different profiles"""
     profile = util.Profile(bulletin, 'profile3b1.txt')
     cspConstructor = submission.SchedulingCSPConstructor(
         bulletin, copy.deepcopy(profile))
     csp = cspConstructor.get_basic_csp()
     cspConstructor.add_unit_constraints(csp)
     alg = submission.BacktrackingSearch()
     alg.solve(csp)
예제 #4
0
파일: grader.py 프로젝트: jhmuller/XCS221
 def test_2(self):
     """3a-2-hidden:  Test add_quarter_constraints with no quarter specified"""
     profile = util.Profile(bulletin, 'profile3a2.txt')
     cspConstructor = submission.SchedulingCSPConstructor(
         bulletin, copy.deepcopy(profile))
     csp = cspConstructor.get_basic_csp()
     cspConstructor.add_quarter_constraints(csp)
     alg = submission.BacktrackingSearch()
     alg.solve(csp)
예제 #5
0
파일: grader.py 프로젝트: jhmuller/XCS221
    def test_0(self):
        """3b-0-basic:  Basic test for add_unit_constraints"""
        profile = util.Profile(bulletin, 'profile3b.txt')
        cspConstructor = submission.SchedulingCSPConstructor(
            bulletin, copy.deepcopy(profile))
        csp = cspConstructor.get_basic_csp()
        cspConstructor.add_unit_constraints(csp)
        alg = submission.BacktrackingSearch()
        alg.solve(csp)

        # Verify correctness.
        self.assertEqual(15, alg.numOptimalAssignments)
        for assignment in alg.allAssignments:
            sol = util.extract_course_scheduling_solution(profile, assignment)
            self.assertTrue(verify_schedule(bulletin, profile, sol))
예제 #6
0
import util, submission, sys

if len(sys.argv) < 2:
    print "Usage: %s <profile file (e.g., profile3d.txt)>" % sys.argv[0]
    sys.exit(1)

profilePath = sys.argv[1]
bulletin = util.CourseBulletin('courses.json')
profile = util.Profile(bulletin, profilePath)
profile.print_info()
cspConstructor = submission.SchedulingCSPConstructor(bulletin, profile)
csp = cspConstructor.get_basic_csp()
cspConstructor.add_all_additional_constraints(csp)

alg = submission.BacktrackingSearch()
alg.solve(csp, mcv=True, ac3=True)
if alg.optimalAssignment:
    print alg.optimalWeight
    for key, value in alg.optimalAssignment.items():
        print key, '=', value

print alg.numOptimalAssignments
if alg.numOptimalAssignments > 0:
    print "solution========================="
    solution = util.extract_course_scheduling_solution(profile,
                                                       alg.optimalAssignment)
    util.print_course_scheduling_solution(solution)

for assignment in alg.allAssignments:
    solution = util.extract_course_scheduling_solution(profile, assignment)
    util.print_course_scheduling_solution(solution)