dwave-hybrid icon indicating copy to clipboard operation
dwave-hybrid copied to clipboard

Clarify/update `SplatComposer` behavior

Open randomir opened this issue 2 years ago • 0 comments

Note:

  • hybrid.SplatComposer does not sort output samples by energy

    • subsequent hybrid.ArgMin with the default key="samples.first.energy" might not pick the best sample by energy
    • easily fixed by sorting after compose, with e.g: hybrid.SliceSamples(), or a more explicit hybrid.SliceSamples(sorted_by='energy').
  • hybrid.SplatComposer does not sort input subsamples by energy before composing with a smaller samples set

    • if subsamples generator does not produce sorted sampleset, and is seeded by, say, a single initial state, the output sampleset (containing just one sample) might not be the best

    • easily "fixed" by sorting subsamples generator output

    • but a better fix might be to explode the input sample with hybrid.AggregatedSamples(aggregate=False) before composing with Splat, followed by a truncate with hybrid.SliceSamples(1). So, something like:

      subsampler = (
          hybrid.AggregatedSamples(aggregate=False)
          | hybrid.SimulatedAnnealingProblemSampler()
          | hybrid.SplatComposer()
          | hybrid.SliceSamples(1, ordered_by='energy')
      )
      

      would make sure the best sample is generated, accounting for boundary conditions.

(Originally raised offline by @jackraymond)

randomir avatar Dec 07 '22 23:12 randomir