QuantumRandomAccessEncoding#

class QuantumRandomAccessEncoding(max_vars_per_qubit=3)[fuente]#

Bases: object

This class specifies a Quantum Random Access Code that can be used to encode the binary variables of a QUBO (quadratic unconstrained binary optimization problem).

Parámetros:

max_vars_per_qubit (int) – The maximum number of decision variables per qubit. Integer values 1, 2 and 3 are supported (default to 3).

Attributes

compression_ratio#

Compression ratio. Number of decision variables divided by number of qubits

frozen#

Whether the object is frozen or not.

max_vars_per_qubit#

Maximum number of variables per qubit

minimum_recovery_probability#

Minimum recovery probability, as set by max_vars_per_qubit

num_qubits#

Number of qubits

num_vars#

Number of decision variables

offset#

Relaxed Hamiltonian offset

Muestra:

RuntimeError – If the offset has not been set yet. Use the encode method to construct the Hamiltonian, or make sure that the objective function has been set.

problem#

The QuadraticProgram encoding a QUBO optimization problem

Muestra:

RuntimeError – If the QuadraticProgram has not been set yet. Use the encode method to set the problem.

q2vars#

Each element contains the list of decision variable indices encoded on that qubit

qubit_op#

Relaxed Hamiltonian operator.

Muestra:

RuntimeError – If the objective function has not been set yet. Use the encode method to construct the Hamiltonian, or make sure that the objective function has been set.

var2op#

Maps each decision variable to (qubit_index, operator)

Methods

encode(problem)[fuente]#

Encodes a given QuadraticProgram as a (n,1,p) Quantum Random Access Code (QRAC) relaxed Hamiltonian. It accomplishes this by mapping each binary decision variable to one qubit of the QRAC. The encoding is designed to ensure that the problem’s objective function commutes with the QRAC encoding.

After the function is called, it sets the following attributes:
  • qubit_op: The qubit operator that encodes the input QuadraticProgram.

  • offset: The constant value in the encoded Hamiltonian.

  • problem: The original QuadraticProgram used for encoding.

Inputs:

problem: A QuadraticProgram encoding a QUBO optimization problem

Muestra:
freeze()[fuente]#

Freeze the object to prevent further modification.

Once an instance of this class is frozen, encode can no longer be called.

state_preparation_circuit(x)[fuente]#

Generate a circuit that prepares the state corresponding to the given binary string.

Parámetros:

x (list[int]) – A list of binary values to be encoded into the state.

Devuelve:

A QuantumCircuit that prepares the state corresponding to the given binary string.

Tipo del valor devuelto:

QuantumCircuit