def do_test(n, cmd, pi, nsolns, complete=True): solns = solve_schedules(pi, 'GAC', complete, 'mrv', True) if len(solns) != nsolns: fails[n] = True print("Error: expected {} solution()s got {}".format(nsolns, len(solns))) for s in solns: if not check_schedule_solution(pi, s): print("Error: got invalid solution") fails[n] = True break if fails[n]: print("\nFail Q6 test {}\nErrors were generated on the following code:".format(n+1)) print(cmd) else: print("Pass Q6 test {}".format(n+1)) print_sep()
parser.add_argument("-v", "--varHeur", help="Heuristic for selecting next variable to assign", choices=['fixed', 'random', 'mrv'], default='mrv') parser.add_argument("-t", "--trace", help="Trace the search", action="store_true") args = parser.parse_args() if args.p < 1 or args.p > len(problems): print("{} is invalid problem number. I only know about problems {} to {}".format(args.b, 1, len(boards))) print("If you want to add new problems define them and add them to the list \"problems\"") exit(1) ip = problems[args.p-1] print("="*66) print("Solving problem {}".format(args.p)) print("Courses: {}".format(ip.courses)) print("Classes: {}".format(ip.classes)) print("Buildings: {}".format(ip.buildings)) print("Adjacency List:") for i in ip.buildings: print("Building {}: {}".format(i, ip.connected_buildings(i))) print("Rest Frequency: {}".format(ip.min_rest_frequency)) print("Number of Time Slots: {}".format(ip.num_time_slots)) print("Solving using {}".format(args.algorithm)) solns = csp_problems.solve_schedules(ip, args.algorithm, args.allSolns, args.varHeur, False, args.trace) print("") for i, s in enumerate(solns): print("Solution {}.".format(i+1)) if not check_schedule_solution(ip, s): print("ERROR solution is invalid") print(s) print("------------------------------\n")