def do_test(n, cmd, pi, nsolns, complete=True): solns = solve_planes(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_plane_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') 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(problems)) 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 "Planes: {}".format(ip.planes) print "Flights: {}".format(ip.flights) print "Solving using {}".format(args.algorithm) solns = csp_problems.solve_planes(ip, args.algorithm, args.allSolns, args.varHeur) print "" for i, s in enumerate(solns): print "Solution {}.".format(i + 1) if not check_plane_solution(ip, s): print "ERROR solution is invalid" s.sort(key=lambda x: x[0]) for l in s: print "Plane {}: {}".format(l[0], l[1:]) print "------------------------------\n"