SamplerRandomBitstrings#

Module: iqm.qaoa.backends

class iqm.qaoa.backends.SamplerRandomBitstrings[source]#

Bases: SamplerBackend

A sampler that ignores the QAOA and just produces random bitstrings of the correct length.

Methods

sample

Produce random bitstrings to act as samples from the QAOA.

sample(qaoa_object, shots, seed=None)[source]#

Produce random bitstrings to act as samples from the QAOA.

The qaoa_object is used only to get the number of qubits (which corresponds to the length of the bitstrings). The number of uniformly random bitstrings produced is shots and they are arranged in a dictionary just like counts from a qiskit measurement.

This method overrides the dispatching method sample() of SamplerBackend because there is no point in doing any kind of dispatching here.

Parameters:
  • qaoa_object (QAOA) – The QAOA object, only used to get the number of qubits.

  • shots (int) – The number of random strings to generate.

  • seed (int | None) – The seed to be used in the random bitstring generation. Optional parameter.

Returns:

A dictionary whose keys are the produced random bitstrings and values their frequencies in the random set.

Return type:

dict[str, int]

Inheritance

Inheritance diagram of iqm.qaoa.backends.SamplerRandomBitstrings