SamplerSimulation

SamplerSimulation#

class iqm.qaoa.backends.SamplerSimulation(simulator=AerSimulator('aer_simulator_statevector'), transpiler=None)[source]#

Bases: SamplerBackend

A sampler that simulates the QAOA circuit in qiskit.

Some simulators may need the circuit to be transpiled, so optionally a string describing the transpiler can be provided.

Parameters:
  • simulator (BackendV2) – A simulator, (currently) assumed to be an object of class AerSimulator.

  • transpiler (str | None) – A string describing the transpilation method to use (if applicable).

Methods

sample(qaoa_object, shots)

Samples from the QAOA using a simulation.

sample(qaoa_object, shots)[source]#

Samples from the QAOA using a simulation.

The dictionary of counts is obtained from qiskit and then the bitstrings are reversed, so they don’t use the qiskit convention of the first bit being on the right of the bitstring.

Parameters:
  • qaoa_object (QUBOQAOA) – The QUBOQAOA object, to be sampled from.

  • shots (int) – The number of samples (measurements) to take.

Returns:

A dictionary whose keys are the measured bitstrings and values their frequencies in the results.

Return type:

dict[str, int]