QAOAClient¶
- class QAOAClient(optimizer=None, reps=1, initial_state=None, mixer=None, initial_point=None, alpha=1.0, provider=None, backend=None, shots=1024, measurement_error_mitigation=False, callback=None, store_intermediate=False, use_swap_strategies=False, use_initial_mapping=False, use_pulse_efficient=False, optimization_level=None)[source]¶
Bases:
VQEClient
The Qiskit Optimization QAOA Runtime Client.
- Parameters
optimizer (
Union
[Optimizer
,Dict
[str
,Any
],None
]) – An optimizer or dictionary specifying a classical optimizer. If a dictionary, only SPSA and QN-SPSA are supported. The dictionary must contain a keyname
for the name of the optimizer and may contain additional keys for the settings. E.g.{'name': 'SPSA', 'maxiter': 100}
. Per default, SPSA is used.reps (
int
) – the integer parameter \(p\) as specified in https://arxiv.org/abs/1411.4028, Has a minimum valid value of 1.initial_state (
Optional
[QuantumCircuit
]) – An optional initial state to prepend the QAOA circuit withmixer (
Union
[QuantumCircuit
,OperatorBase
,None
]) – the mixer Hamiltonian to evolve with or a custom quantum circuit. Allows support of optimizations in constrained subspaces as per https://arxiv.org/abs/1709.03489 as well as warm-starting the optimization as introduced in http://arxiv.org/abs/2009.10095.initial_point (
Optional
[ndarray
]) – An optional initial point (i.e. initial parameter values) for the optimizer. IfNone
a random vector is chosen in theVQE
class in Qiskit terra using a uniform distribution.alpha (
float
) – The fraction of top measurement samples to be used for the expectation value (CVaR expectation). Defaults to 1, i.e. using all samples to construct the expectation value. This value must be contained in the interval [0, 1].provider (
Optional
[Provider
]) – The provider.backend (
Optional
[Backend
]) – The backend to run the circuits on.shots (
int
) – The number of shots to be usedmeasurement_error_mitigation (
bool
) – Whether or not to use measurement error mitigation.callback (
Optional
[Callable
[[int
,ndarray
,float
,float
],None
]]) – a callback that can access the intermediate data during the optimization. Four parameter values are passed to the callback as follows during each evaluation by the optimizer for its current set of parameters as it works towards the minimum. These are: the evaluation count, the optimizer parameters for the ansatz, the evaluated mean and the evaluated standard deviation.store_intermediate (
bool
) – Whether or not to store intermediate values of the optimization steps. Per default False.use_swap_strategies (
bool
) – A boolean on whether or not to use swap strategies when transpiling. If this is False then the standard transpiler with the given optimization level will run.use_initial_mapping (
bool
) – A boolean flag that, if set to True (the default is False), runs a heuristic algorithm to permute the Paulis in the cost operator to better fit the coupling map and the swap strategy. This is only needed when the optimization problem is sparse and when using swap strategies to transpile.use_pulse_efficient (
bool
) – A boolean on whether or not to use a pulse-efficient transpilation. If this flag is set to False by default. See https://arxiv.org/abs/2105.01063.optimization_level (
Optional
[int
]) – The transpiler optimization level to run if the swap strategies are not used. This value defaults to 1 in the QAOA runtime.
- Raises
QiskitOptimizationError – if reps is smaller than 1.
QiskitOptimizationError – if alpha is not in the interval [0, 1].
QiskitOptimizationError – if optimization_level is not None and use_swap_strategies is True.
Attributes
The fraction of best shots to keep.
Return the ansatz.
Returns: Returns the initial state.
Returns: Returns the mixer.
Return the optimization level to use if swap strategies are not used.
Returns: Returns the reps.
If True run a permutation of the decision variables to better fit the device.
If True then a pulse-efficient transpiler pass will run to scale the CR gates.
Whether or not the transpilation will use the swap strategies.
Methods
program_inputs
(operator[, aux_operators])Return the QAOA program inputs