QuantumRandomAccessOptimizer#
- class QuantumRandomAccessOptimizer(min_eigen_solver, max_vars_per_qubit=3, rounding_scheme=None, *, penalty=None)[source]#
Bases:
OptimizationAlgorithm
Quantum Random Access Optimizer class.
- Parameters:
min_eigen_solver (MinimumEigensolver) – The minimum eigensolver to use for solving the relaxed problem.
max_vars_per_qubit (int) – The maximum number of decision variables per qubit. Integer values 1, 2 and 3 are supported (default to 3).
rounding_scheme (RoundingScheme | None) – The rounding scheme. If
None
is provided,SemideterministicRounding
will be used.penalty (float | None) – The penalty factor to use for the
QuadraticProgramToQubo
converter.
- Raises:
ValueError – If the maximum number of variables per qubit is not 1, 2, or 3.
TypeError – If the provided minimum eigensolver does not support auxiliary operators.
Attributes
- max_vars_per_qubit#
Return the maximum number of variables per qubit.
- min_eigen_solver#
Return the minimum eigensolver.
- rounding_scheme#
Return the rounding scheme.
Methods
- get_compatibility_msg(problem)[source]#
Checks whether a given problem can be solved with this optimizer.
Checks whether the given problem is compatible, i.e., whether the problem can be converted to a QUBO, and otherwise, returns a message explaining the incompatibility.
- Parameters:
problem (QuadraticProgram) – The optimization problem to check compatibility.
- Returns:
A message describing the incompatibility.
- Return type:
- is_compatible(problem)#
Checks whether a given problem can be solved with the optimizer implementing this method.
- Parameters:
problem (QuadraticProgram) – The optimization problem to check compatibility.
- Returns:
Returns True if the problem is compatible, False otherwise.
- Return type:
- process_result(problem, encoding, relaxed_result, rounding_result)[source]#
Process the relaxed result of the minimum eigensolver and rounding scheme.
- Parameters:
problem (QuadraticProgram) – The
QuadraticProgram
to be solved.encoding (QuantumRandomAccessEncoding) – An encoding instance for which
encode()
has already been called so it has been encoded with aQuadraticProgram
.relaxed_result (MinimumEigensolverResult) – The relaxed result of the minimum eigensolver.
rounding_result (RoundingResult) – The result of the rounding scheme.
- Returns:
The result of the quantum random access optimization.
- Return type:
- solve(problem)[source]#
Solve the relaxed Hamiltonian given by the encoding and round the solution by the given rounding scheme.
- Parameters:
problem (QuadraticProgram) – The
QuadraticProgram
to be solved.- Returns:
The result of the quantum random access optimization.
- Raises:
ValueError – If the encoding has not been encoded with a
QuadraticProgram
.- Return type:
- solve_relaxed(encoding)[source]#
Solve the relaxed Hamiltonian given by the encoding.
Note
This method uses the encoding instance given as
encoding
and ignoresmax_vars_per_qubit()
.- Parameters:
encoding (QuantumRandomAccessEncoding) – An encoding instance for which
encode()
has already been called so it has been encoded with aQuadraticProgram
.- Returns:
The result of the minimum eigensolver, and the rounding context.
- Raises:
ValueError – If the encoding has not been encoded with a
QuadraticProgram
.- Return type:
tuple[MinimumEigensolverResult, RoundingContext]