qml.qaoa.cost.bit_driver¶
- bit_driver(wires, b)[source]¶
Returns the bit-driver cost Hamiltonian.
This Hamiltonian is defined as:
H = (−1)b+1∑iZiwhere Zi is the Pauli-Z operator acting on the i-th wire and b ∈ {0, 1}. This Hamiltonian is often used when constructing larger QAOA cost Hamiltonians.
- Parameters
wires (Iterable or Wires) – The wires on which the Hamiltonian acts
b (int) – Either 0 or 1. Determines whether the Hamiltonian assigns lower energies to bitstrings with a majority of bits being 0 or a majority of bits being 1, respectively.
- Returns
- Return type
Hamiltonian
Example
>>> wires = range(3) >>> hamiltonian = qaoa.bit_driver(wires, 1) >>> print(hamiltonian) 1 * Z(0) + 1 * Z(1) + 1 * Z(2)