TransWikia.com

How to build an ExpectationBase object?

Quantum Computing Asked on December 8, 2020

I’m trying to wrap my head around the expectation argument in Qiskit’s VQE class, so to understand it I’m trying to create an ExpectationBase object to understand it better, but I’m getting nowhere. Can anyone give a hand?

One Answer

The VQE computes the expectation values of the input operator with respect to the parameterized ansatz circuit. There are different ways to compute this expectation value, e.g. you could

  • convert operator to a matrix, the ansatz circuit to a statevector and compute the dot-product, or
  • convert the operator to Pauli strings, diagonalize the ansatz circuit in each basis of the Pauli strings and measure.

The expectation argument allows you to choose the kind of expectation computation you want to use.

  • qiskit.aqua.operators.MatrixExpectation does the dot product
  • qiskit.aqua.operators.PauliExpectation does the Pauli string transform (this is what you would do on real quantum hardware)
  • qiskit.aqua.operators.AerPauliExpectation uses a special expectation value from Qiskit's Aer element

A bit more advanced:

If you were to create your own kind of expectation computation you can check how MatrixExpectation or PauliExpectation are implemented. They require some knowledge of how the operator flow in Aqua works though. In brief, the ExpectationValue provides a convert method that maps an operator expression that realizes the expectation value (something like OperatorMeasurement @ StateFn) to a new expression that implements your expectation value scheme. For MatrixExpectation this means converting all operators to matrices and for PauliExpectation this means converting the operator to Pauli strings and applying the right basis transformations to the ansatz circuit.

Correct answer by Cryoris on December 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP