diff --git a/qde.py b/qde.py index 43a2416..8791c57 100644 --- a/qde.py +++ b/qde.py @@ -451,12 +451,13 @@ def solve_ode_qubo(system_terms, grid, known_points, bits_integer, bits_decimal, job_label = f'Point {known_points.shape[1]}; Eq. {eq_ind}; Attempt {attempt + 1}' sample_set = sampler.sample_qubo(Q, label=job_label, **kwargs) samples_plain = np.array([list(sample.values()) for sample in sample_set]) # 2D, each row - solution (all bits together), sorted by energy - solution_error = sample_set.data_vectors['energy'][0] + energy_shift + trial_bits = samples_plain[0, :] + solution_error = np.dot(np.matmul(trial_bits, Q), trial_bits) + energy_shift log.write(f'{job_label}; Error {solution_error}\n') if solution_error < lowest_error: lowest_error = solution_error - solution_bits = samples_plain[0, :] + solution_bits = trial_bits if solution_error < max_error: break diff --git a/test_core.py b/test_core.py index a92978f..c1b1991 100644 --- a/test_core.py +++ b/test_core.py @@ -182,9 +182,9 @@ def get_qubo_solution(problem, N=100, time_max=400, initial_position=1.3, bits_i def main(): - # grid, sln, errors = get_qubo_solution(problem=21, N=200) + # grid, sln, errors = get_qubo_solution(problem=21, N=50, time_max=400, sampler_name='qbsolv', num_repeats=100) - _, solution, error = get_qubo_solution(problem=21, N=50, time_max=400, sampler_name='dwave', max_attempts=5, max_error=1e-5, num_reads=10000) + _, solution, error = get_qubo_solution(problem=21, N=50, time_max=400, sampler_name='dwave', max_attempts=10, max_error=5e-10, num_reads=10000) np.savetxt('solution.txt', solution) np.savetxt('error.txt', error)