dwavesystems / dwave-samplers

Classical algorithms for solving binary quadratic models
Apache License 2.0
8 stars 12 forks source link

Add RandomSampler #24

Closed arcondello closed 2 years ago

arcondello commented 2 years ago

Add a performant random sampler. This is intended to replace dimod.RandomSampler as part of https://github.com/dwavesystems/dimod/issues/298.

This implements the same API, but also includes a time_limit parameter. This is a feature used by the benchmarking team - this sampler is meant to replace their random batch sampler with one maintained as part of Ocean.

I have also attempted to include timing information following the spec in https://github.com/dwavesystems/dwave-samplers/issues/22.

I kind of hate that, because we list the samplers alphabetically, this one gets put first :shrug:.

arcondello commented 2 years ago

This relies on an unreleased dimod feature - hence the CI failures. ~Will open a PR shortly.~ https://github.com/dwavesystems/dimod/pull/1210

arcondello commented 2 years ago

Ok, refactored. Now both num_reads and time_limit are termination criteria. Added max_num_samples to limit the population of samples kept internally. I defaulted max_num_samples to 1000. It's a magic number, but I don't think it would be "safe" to leave it unbounded. The sampler is rather fast and can generate many samples for even short runtimes.

I also have dropped the timing info, pending a decision on #22. We can restore it in a followup PR.