# Output a file in any of a variety of formats. Note that we've already # handled qbsolv output and QMASM output as special cases. if cl_args.format != "qmasm" and (cl_args.output != "<stdout>" or not cl_args.run): qmasm.write_output(physical, cl_args.output, cl_args.format, cl_args.qubo) # If we weren't told to run anything we can exit now. if not cl_args.run: sys.exit(0) # Submit the problem to the D-Wave. if cl_args.verbose >= 1: sys.stderr.write("Submitting the problem to the %s solver.\n\n" % qmasm.solver_name) answer, final_answer, num_occurrences = qmasm.submit_dwave_problem( cl_args.verbose, physical, cl_args.samples, cl_args.anneal_time, cl_args.spin_revs, cl_args.postproc) # Output solver timing information. if cl_args.verbose >= 1: try: timing_info = answer["timing"].items() sys.stderr.write("Timing information:\n\n") sys.stderr.write(" %-30s %-10s\n" % ("Measurement", "Value (us)")) sys.stderr.write(" %s %s\n" % ("-" * 30, "-" * 10)) for timing_value in timing_info: sys.stderr.write(" %-30s %10d\n" % timing_value) sys.stderr.write("\n") except KeyError: # Not all solvers provide timing information. pass
pass else: qmasm.write_output(physical_ising, cl_args.output, cl_args.format, cl_args.qubo) # If we weren't told to run anything we can exit now. if not cl_args.run: sys.exit(0) # Submit the problem to the D-Wave. if cl_args.verbose >= 1: sys.stderr.write("Submitting the problem to the %s solver.\n\n" % qmasm.solver_name) dwave_response = qmasm.submit_dwave_problem(cl_args.verbose, physical_ising, cl_args.samples, cl_args.anneal_time, cl_args.spin_revs, cl_args.postproc, cl_args.discard) answer, final_answer, num_occurrences, num_not_broken = dwave_response # Output solver timing information. if cl_args.verbose >= 1: try: timing_info = list(answer["timing"].items()) sys.stderr.write("Timing information:\n\n") sys.stderr.write(" %-30s %-10s\n" % ("Measurement", "Value (us)")) sys.stderr.write(" %s %s\n" % ("-" * 30, "-" * 10)) for timing_value in timing_info: sys.stderr.write(" %-30s %10d\n" % timing_value) sys.stderr.write("\n") except KeyError:
physical = qmasm.scale_weights_strengths(physical, cl_args.verbose) # Output a file in any of a variety of formats. Note that we've already # handled qbsolv output as a special case. if cl_args.output != "<stdout>" or not cl_args.run: qmasm.write_output(physical, cl_args.output, cl_args.format, cl_args.qubo) # If we weren't told to run anything we can exit now. if not cl_args.run: sys.exit(0) # Submit the problem to the D-Wave. if cl_args.verbose >= 1: sys.stderr.write("Submitting the problem to the %s solver.\n\n" % qmasm.solver_name) answer, final_answer, num_occurrences = qmasm.submit_dwave_problem( physical, cl_args.samples, cl_args.anneal_time) # Output solver timing information. if cl_args.verbose >= 1: try: timing_info = answer["timing"].items() sys.stderr.write(" %-30s %-10s\n" % ("Measurement", "Value (us)")) sys.stderr.write(" %s %s\n" % ("-" * 30, "-" * 10)) for timing_value in timing_info: sys.stderr.write(" %-30s %10d\n" % timing_value) sys.stderr.write("\n") except KeyError: # Not all solvers provide timing information. pass
# Don't write a QMASM file if we already did so before embedding. pass else: qmasm.write_output(physical_ising, cl_args.output, cl_args.format, cl_args.qubo) # If we weren't told to run anything we can exit now. if not cl_args.run: sys.exit(0) # Submit the problem to the D-Wave. if cl_args.verbose >= 1: sys.stderr.write("Submitting the problem to the %s solver.\n\n" % qmasm.solver_name) solutions = qmasm.submit_dwave_problem(cl_args.verbose, physical_ising, cl_args.samples, cl_args.anneal_time, cl_args.spin_revs, cl_args.postproc) # Output solver timing information. if cl_args.verbose >= 1: try: timing_info = list(solutions.answer["timing"].items()) sys.stderr.write("Timing information:\n\n") sys.stderr.write(" %-30s %-10s\n" % ("Measurement", "Value (us)")) sys.stderr.write(" %s %s\n" % ("-" * 30, "-" * 10)) for timing_value in sorted(timing_info): sys.stderr.write(" %-30s %10d\n" % timing_value) sys.stderr.write("\n") except KeyError: # Not all solvers provide timing information. pass
if cl_args.format == "qmasm": # Don't write a QMASM file if we already did so before embedding. pass else: qmasm.write_output(physical_ising, cl_args.output, cl_args.format, cl_args.qubo) # If we weren't told to run anything we can exit now. if not cl_args.run: sys.exit(0) # Submit the problem to the D-Wave. if cl_args.verbose >= 1: sys.stderr.write("Submitting the problem to the %s solver.\n\n" % qmasm.solver_name) solutions = qmasm.submit_dwave_problem(cl_args.verbose, physical_ising, cl_args.samples, cl_args.anneal_time, cl_args.spin_revs, cl_args.postproc) # Output solver timing information. if cl_args.verbose >= 1: try: timing_info = list(solutions.answer["timing"].items()) sys.stderr.write("Timing information:\n\n") sys.stderr.write(" %-30s %-10s\n" % ("Measurement", "Value (us)")) sys.stderr.write(" %s %s\n" % ("-" * 30, "-" * 10)) for timing_value in sorted(timing_info): sys.stderr.write(" %-30s %10d\n" % timing_value) sys.stderr.write("\n") except KeyError: # Not all solvers provide timing information.