mqt.problemsolver.satellite_solver.algorithms

Module Contents

solve_using_qaoa(qubo: numpy.typing.NDArray[numpy.float64], noisy_flag: bool = True, layers: int = 10, num_init: int = 5) → float[source]
solve_using_vqe(qubo: numpy.typing.NDArray[numpy.float64], noisy_flag: bool = True, ansatz: QuantumCircuit | None = None, num_init: int = 5) → float[source]
bitstring_to_vector(bitstring: str) → numpy.typing.NDArray[int_][source]

Convert a bitstring to a vector of integers.

compute_expectation(counts: dict[str, int], qubo: numpy.typing.NDArray[numpy.float64]) → float[source]

Computes the expectation value of the quadratic form Q with respect to the given counts.

Parameters:
  • counts – A dictionary where keys are bitstrings and values are their counts.

  • qubo – The QUBO matrix represented as a NumPy array.

Returns:

float

The expectation value of the quadratic form Q with respect to the counts.

cost_func(params: numpy.typing.NDArray[numpy.float64], circuit: QuantumCircuit, backend: BackendV2, qubo: numpy.typing.NDArray[numpy.float64]) → float[source]

Computes the cost function for QAOA optimization.

Parameters:
  • params – An array of floats representing the parameters for the QAOA circuit

  • circuit – The QuantumCircuit representing the QAOA circuit to be evaluated.

  • backend – The backend to run the circuit on.

  • qubo – The QUBO matrix representing the problem.

Returns:

A float representing the expectation value of the QUBO Hamiltonian with respect to the states produced by the circuit.

optimize_with_multiple_init_parameters(num_init: int, circuit: QuantumCircuit, backend: BackendV2, qubo: numpy.typing.NDArray[numpy.float64]) → tuple[list[float], QuantumCircuit][source]

Optimizes the QAOA parameters using multiple random initializations.

Parameters:
  • num_init – The number of random initializations to perform.

  • circuit – The QuantumCircuit representing the QAOA circuit to be optimized.

  • backend – The backend to run the circuit on.

  • qubo – The QUBO matrix representing the problem.

Returns:

A list of floats representing the optimized parameters that minimize the cost function.

evaluate_result(num_init: int, circuit: QuantumCircuit, backend: BackendV2, qubo: numpy.typing.NDArray[numpy.float64]) → tuple[str, int, float][source]

Evaluates the result of the QAOA circuit.

Parameters:
  • num_init – The number of initializations to perform.

  • circuit – The QAOA circuit to be evaluated.

  • backend – The backend to run the circuit on.

  • qubo – The QUBO matrix representing the problem.

Returns:

  • The found state as a bitstring.

  • The count of that state.

  • The energy computed from the QUBO matrix.

class QAOA(qubo: numpy.typing.NDArray[numpy.float64], layers: int, num_init: int, backend: BackendV2, reps: int = 2)[source]
qubo
layers
num_init
backend
reps = 2
get_solution() → tuple[QuantumCircuit, float][source]

Returns the quantum circuit of the QAOA algorithm and the resulting solution.

Returns:

  • The QAOA circuit (QuantumCircuit) of the solution.

  • The computed energy (float) of the solution.

class VQE(qubo: numpy.typing.NDArray[numpy.float64], backend: BackendV2, ansatz: QuantumCircuit | None = None, num_init: int = 1)[source]
qubo
backend
num_init = 1
get_solution() → tuple[QuantumCircuit, float][source]

Returns the quantum circuit of the VQE algorithm and the resulting solution.

Returns:

  • The VQE circuit (QuantumCircuit) of the solution.

  • The computed energy (float) of the solution.