160 lines
9.7 KiB
Plaintext
160 lines
9.7 KiB
Plaintext
---
|
||
title: VQD
|
||
description: API reference for qiskit.algorithms.eigensolvers.VQD
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.algorithms.eigensolvers.VQD
|
||
---
|
||
|
||
# VQD
|
||
|
||
<Class id="qiskit.algorithms.eigensolvers.VQD" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.24/qiskit/algorithms/eigensolvers/vqd.py" signature="VQD(estimator, fidelity, ansatz, optimizer, *, k=2, betas=None, initial_point=None, callback=None)" modifiers="class">
|
||
Bases: `VariationalAlgorithm`, [`Eigensolver`](qiskit.algorithms.eigensolvers.Eigensolver "qiskit.algorithms.eigensolvers.eigensolver.Eigensolver")
|
||
|
||
The Variational Quantum Deflation algorithm. Implementation using primitives.
|
||
|
||
[VQD](https://arxiv.org/abs/1805.08138) is a quantum algorithm that uses a variational technique to find the k eigenvalues of the Hamiltonian $H$ of a given system.
|
||
|
||
The algorithm computes excited state energies of generalised hamiltonians by optimising over a modified cost function where each succesive eigenvalue is calculated iteratively by introducing an overlap term with all the previously computed eigenstates that must be minimised, thus ensuring higher energy eigenstates are found.
|
||
|
||
An instance of VQD requires defining three algorithmic sub-components: an integer k denoting the number of eigenstates to calculate, a trial state (a.k.a. ansatz) which is a `QuantumCircuit`, and one instance (or list of) classical [`optimizers`](qiskit.algorithms.optimizers#module-qiskit.algorithms.optimizers "qiskit.algorithms.optimizers"). The optimizer varies the circuit parameters The trial state $|\psi(\vec\theta)\rangle$ is varied by the optimizer, which modifies the set of ansatz parameters $\vec\theta$ such that the expectation value of the operator on the corresponding state approaches a minimum. The algorithm does this by iteratively refining each excited state to be orthogonal to all the previous excited states.
|
||
|
||
An optional array of parameter values, via the *initial\_point*, may be provided as the starting point for the search of the minimum eigenvalue. This feature is particularly useful when there are reasons to believe that the solution point is close to a particular point.
|
||
|
||
The length of the *initial\_point* list value must match the number of the parameters expected by the ansatz. If the *initial\_point* is left at the default of `None`, then VQD will look to the ansatz for a preferred value, based on its given initial state. If the ansatz returns `None`, then a random point will be generated within the parameter bounds set, as per above. It is also possible to give a list of initial points, one for every kth eigenvalue. If the ansatz provides `None` as the lower bound, then VQD will default it to $-2\pi$; similarly, if the ansatz returns `None` as the upper bound, the default value will be $2\pi$.
|
||
|
||
The following attributes can be set via the initializer but can also be read and updated once the VQD object has been constructed.
|
||
|
||
### estimator
|
||
|
||
<Attribute id="qiskit.algorithms.eigensolvers.VQD.estimator">
|
||
The primitive instance used to perform the expectation estimation as indicated in the VQD paper.
|
||
|
||
**Type**
|
||
|
||
[BaseEstimator](qiskit.primitives.BaseEstimator "qiskit.primitives.BaseEstimator")
|
||
</Attribute>
|
||
|
||
### fidelity
|
||
|
||
<Attribute id="qiskit.algorithms.eigensolvers.VQD.fidelity">
|
||
The fidelity class instance used to compute the overlap estimation as indicated in the VQD paper.
|
||
|
||
**Type**
|
||
|
||
[BaseStateFidelity](qiskit.algorithms.state_fidelities.BaseStateFidelity "qiskit.algorithms.state_fidelities.BaseStateFidelity")
|
||
</Attribute>
|
||
|
||
### ansatz
|
||
|
||
<Attribute id="qiskit.algorithms.eigensolvers.VQD.ansatz">
|
||
A parameterized circuit used as ansatz for the wave function.
|
||
|
||
**Type**
|
||
|
||
[QuantumCircuit](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")
|
||
</Attribute>
|
||
|
||
### optimizer
|
||
|
||
<Attribute id="qiskit.algorithms.eigensolvers.VQD.optimizer">
|
||
A classical optimizer or a list of optimizers, one for every k-th eigenvalue. Can either be a Qiskit optimizer or a callable that takes an array as input and returns a Qiskit or SciPy optimization result.
|
||
|
||
**Type**
|
||
|
||
[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer") | Sequence\[[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer")]
|
||
</Attribute>
|
||
|
||
### k
|
||
|
||
<Attribute id="qiskit.algorithms.eigensolvers.VQD.k">
|
||
the number of eigenvalues to return. Returns the lowest k eigenvalues.
|
||
|
||
**Type**
|
||
|
||
int
|
||
</Attribute>
|
||
|
||
### betas
|
||
|
||
<Attribute id="qiskit.algorithms.eigensolvers.VQD.betas">
|
||
Beta parameters in the VQD paper. Should have length k - 1, with k the number of excited states. These hyper-parameters balance the contribution of each overlap term to the cost function and have a default value computed as the mean square sum of the coefficients of the observable.
|
||
|
||
**Type**
|
||
|
||
list\[float]
|
||
</Attribute>
|
||
|
||
### callback
|
||
|
||
<Attribute id="qiskit.algorithms.eigensolvers.VQD.callback">
|
||
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: the evaluation count, the optimizer parameters for the ansatz, the estimated value, the estimation metadata, and the current step.
|
||
|
||
**Type**
|
||
|
||
Callable\[\[int, np.ndarray, float, dict\[str, Any]], None] | None
|
||
</Attribute>
|
||
|
||
**Parameters**
|
||
|
||
* **estimator** ([*BaseEstimator*](qiskit.primitives.BaseEstimator "qiskit.primitives.BaseEstimator")) – The estimator primitive.
|
||
* **fidelity** ([*BaseStateFidelity*](qiskit.algorithms.state_fidelities.BaseStateFidelity "qiskit.algorithms.state_fidelities.BaseStateFidelity")) – The fidelity class using primitives.
|
||
* **ansatz** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) – A parameterized circuit used as ansatz for the wave function.
|
||
* **optimizer** ([*Optimizer*](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer") *|*[*Minimizer*](qiskit.algorithms.optimizers.Minimizer "qiskit.algorithms.optimizers.Minimizer") *| Sequence\[*[*Optimizer*](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer") *|*[*Minimizer*](qiskit.algorithms.optimizers.Minimizer "qiskit.algorithms.optimizers.Minimizer")*]*) – A classical optimizer or a list of optimizers, one for every k-th eigenvalue.
|
||
* **callable** (*Can either be a Qiskit optimizer or a*) – that takes an array as input and returns a Qiskit or SciPy optimization result.
|
||
* **k** (*int*) – The number of eigenvalues to return. Returns the lowest k eigenvalues.
|
||
* **betas** (*Sequence\[float] | None*) – Beta parameters in the VQD paper. Should have length k - 1, with k the number of excited states. These hyperparameters balance the contribution of each overlap term to the cost function and have a default value computed as the mean square sum of the coefficients of the observable.
|
||
* **initial\_point** (*Sequence\[float] | Sequence\[Sequence\[float]] | None*) – An optional initial point (i.e. initial parameter values) or a list of initial points (one for every k-th eigenvalue) for the optimizer. If `None` then VQD will look to the ansatz for a preferred point and if not will simply compute a random one.
|
||
* **callback** (*Callable\[\[int, np.ndarray, float, dict\[str, Any]], None] | 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: the evaluation count, the optimizer parameters for the ansatz, the estimated value, the estimation metadata, and the current step.
|
||
|
||
## Methods
|
||
|
||
<span id="qiskit-algorithms-eigensolvers-vqd-compute-eigenvalues" />
|
||
|
||
### compute\_eigenvalues
|
||
|
||
<Function id="qiskit.algorithms.eigensolvers.VQD.compute_eigenvalues" signature="VQD.compute_eigenvalues(operator, aux_operators=None)">
|
||
Computes the minimum eigenvalue. The `operator` and `aux_operators` are supplied here. While an `operator` is required by algorithms, `aux_operators` are optional.
|
||
|
||
**Parameters**
|
||
|
||
* **operator** (*BaseOperator |* [*PauliSumOp*](qiskit.opflow.primitive_ops.PauliSumOp "qiskit.opflow.primitive_ops.PauliSumOp")) – Qubit operator of the observable.
|
||
* **aux\_operators** (*ListOrDict\[BaseOperator |* [*PauliSumOp*](qiskit.opflow.primitive_ops.PauliSumOp "qiskit.opflow.primitive_ops.PauliSumOp")*] | None*) – Optional list of auxiliary operators to be evaluated with the eigenstate of the minimum eigenvalue main result and their expectation values returned. For instance, in chemistry, these can be dipole operators and total particle count operators, so we can get values for these at the ground state.
|
||
|
||
**Returns**
|
||
|
||
An eigensolver result.
|
||
|
||
**Return type**
|
||
|
||
[VQDResult](qiskit.algorithms.eigensolvers.VQDResult "qiskit.algorithms.eigensolvers.VQDResult")
|
||
</Function>
|
||
|
||
<span id="qiskit-algorithms-eigensolvers-vqd-supports-aux-operators" />
|
||
|
||
### supports\_aux\_operators
|
||
|
||
<Function id="qiskit.algorithms.eigensolvers.VQD.supports_aux_operators" signature="VQD.supports_aux_operators()" modifiers="classmethod">
|
||
Whether computing the expectation value of auxiliary operators is supported.
|
||
|
||
If the eigensolver computes the eigenvalues of the main operator, then it can compute the expectation value of the `aux_operators` for that state. Otherwise they will be ignored.
|
||
|
||
**Returns**
|
||
|
||
`True` if `aux_operator` expectations can be evaluated, `False` otherwise.
|
||
|
||
**Return type**
|
||
|
||
bool
|
||
</Function>
|
||
|
||
## Attributes
|
||
|
||
### initial\_point
|
||
|
||
<Attribute id="qiskit.algorithms.eigensolvers.VQD.initial_point">
|
||
Returns initial point.
|
||
</Attribute>
|
||
</Class>
|
||
|