MagicRounding#
- class MagicRounding(sampler, basis_sampling='uniform', seed=None)[fuente]#
Bases:
RoundingSchemeMagic rounding scheme that measures in magic bases, and then uses the measurement results to round the solution. Since the magic rounding is based on the measurement results, it requires a quantum backend, which can be either hardware or a simulator.
The details are described in https://arxiv.org/abs/2111.03167.
- Parámetros:
sampler (BaseSampler) – Sampler to use for sampling the magic bases.
basis_sampling (str) – Method to use for sampling the magic bases. Must be either
"uniform"(default) or"weighted"."uniform"samples all magic bases uniformly, and is the method described in https://arxiv.org/abs/2111.03167."weighted"attempts to choose bases strategically using the Pauli expectation values from the minimum eigensolver. However, the approximation bounds given in https://arxiv.org/abs/2111.03167 apply only to"uniform"sampling.seed (int | None) – Seed for random number generator, which is used to sample the magic bases.
- Muestra:
ValueError – If
basis_samplingis not"uniform"or"weighted".ValueError – If the sampler is not configured with a number of shots.
Attributes
- basis_sampling#
Basis sampling method (either
"uniform"or"weighted").
- sampler#
Returns the Sampler used to sample the magic bases.
Methods
- round(rounding_context)[fuente]#
Perform magic rounding using the given RoundingContext.
- Parámetros:
rounding_context (RoundingContext) – The context containing the information needed for the rounding.
- Devuelve:
The results of the magic rounding process.
- Tipo del valor devuelto:
- Muestra:
ValueError – If the rounding context has no circuits.
ValueError – If the rounding context has no expectation values for magic rounding with the weighted sampling.
QiskitOptimizationError – If the magic rounding did not return the expected number of shots.
QiskitOptimizationError – If the magic rounding did not return the expected number of bases.