Ejemplo n.º 1
0
                                       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

# Filter the solutions as directed by the user.
final_solns = solutions.filter(cl_args.show, cl_args.verbose, cl_args.samples)

# Output energy tallies.  We first recompute these because some entries seem to
# be multiply listed.
if cl_args.verbose >= 2:
    qmasm.output_energy_tallies(physical_ising, final_solns.answer, True)
elif cl_args.verbose >= 1:
    qmasm.output_energy_tallies(physical_ising, final_solns.answer, False)

# Output the solution to the standard output device.
show_asserts = cl_args.verbose >= 2 or cl_args.show in ["best", "all"]
qmasm.output_solution(final_solns, cl_args.values, cl_args.verbose,
                      show_asserts)
Ejemplo n.º 2
0
update_final_solns()
if cl_args.verbose >= 1:
    sys.stderr.write("    %*d with no broken pins\n" %
                     (digits, len(solutions.solutions)))
solutions.discard_failed_assertions()
update_final_solns()
if cl_args.verbose >= 1:
    sys.stderr.write("    %*d with no failed assertions\n" %
                     (digits, len(solutions.solutions)))
solutions.discard_non_minimal()
update_final_solns()
if cl_args.verbose >= 1:
    sys.stderr.write("    %*d at minimal energy\n" %
                     (digits, len(solutions.solutions)))
solutions.discard_duplicates()
update_final_solns()
if cl_args.verbose >= 1:
    sys.stderr.write("    %*d excluding duplicate variable assignments\n" %
                     (digits, len(solutions.solutions)))
    sys.stderr.write("\n")

# Output energy tallies.  We first recompute these because some entries seem to
# be multiply listed.
if cl_args.verbose >= 2:
    qmasm.output_energy_tallies(physical_ising, final_solns.answer)

# Output the solution to the standard output device.
show_asserts = cl_args.verbose >= 2 or cl_args.show in ["best", "all"]
qmasm.output_solution(final_solns, cl_args.values, cl_args.verbose,
                      show_asserts)
Ejemplo n.º 3
0
id2solution = {}   # Map from an int to a solution
for snum in range(n_solns_to_output):
    soln = ValidSolution(physical_ising, final_answer[snum], energies[snum])
    bad_assert = any([not a[1] for a in soln.check_assertions()])
    if bad_assert:
        n_assertion_violations += 1
        if not cl_args.all_solns:
            continue
    if soln.id not in id2solution:
        id2solution[soln.id] = soln

# Output information about the raw solutions.
if cl_args.verbose >= 1:
    sys.stderr.write("Number of solutions found:\n\n")
    sys.stderr.write("    %6d total\n" % len(energies))
    sys.stderr.write("    %6d with no broken chains or broken pins\n" % num_not_broken)
    sys.stderr.write("    %6d at minimal energy\n" % n_low_energies)
    sys.stderr.write("    %6d with no failed assertions\n" % (n_low_energies - n_assertion_violations))
    sys.stderr.write("    %6d excluding duplicate variable assignments\n" % len(id2solution))
    sys.stderr.write("\n")

# Output energy tallies.  We first recompute these because some entries seem to
# be multiply listed.
if cl_args.verbose >= 2:
    qmasm.output_energy_tallies(physical_ising, answer, energies)

# Output the solution to the standard output device.
show_asserts = (cl_args.all_solns or cl_args.verbose >= 2) and len(physical_ising.assertions) > 0
qmasm.output_solution(id2solution, num_occurrences, cl_args.values,
                      cl_args.verbose, show_asserts)
Ejemplo n.º 4
0
                                       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

# Filter the solutions as directed by the user.
final_solns = solutions.filter(cl_args.show, cl_args.verbose, cl_args.samples)

# Output energy tallies.  We first recompute these because some entries seem to
# be multiply listed.
if cl_args.verbose >= 2:
    qmasm.output_energy_tallies(physical_ising, final_solns.answer)

# Output the solution to the standard output device.
show_asserts = cl_args.verbose >= 2 or cl_args.show in ["best", "all"]
qmasm.output_solution(final_solns, cl_args.values, cl_args.verbose, show_asserts)