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} \displaystyle\sum_{i} Z_i\]where \(Z_i\) is the Pauli-Z operator acting on the \(i\)-th wire and \(b \ \in \ \{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
Example
>>> wires = range(3) >>> hamiltonian = qaoa.bit_driver(wires, 1) >>> print(hamiltonian) 1 * Z(0) + 1 * Z(1) + 1 * Z(2)
code/api/pennylane.qaoa.cost.bit_driver
Download Python script
Download Notebook
View on GitHub