Ansatz

class Ansatz[source]

Bases: ABC

Abstract base class for all VQE ansätze.

Attributes Summary

name

Returns the human-readable name of the ansatz.

Methods Summary

build(params, n_qubits, n_layers, **kwargs)

Builds the ansatz circuit and returns a list of operations.

n_params_per_layer(n_qubits, **kwargs)

Returns the number of parameters required by the ansatz for one layer.

Attributes Documentation

name

Returns the human-readable name of the ansatz.

Methods Documentation

abstractmethod build(params, n_qubits, n_layers, **kwargs)[source]

Builds the ansatz circuit and returns a list of operations.

Parameters:
  • params – Parameter array for the ansatz.

  • n_qubits (int) – Number of qubits in the circuit.

  • n_layers (int) – Number of ansatz layers.

  • **kwargs – Additional arguments specific to the ansatz.

Returns:

The ansatz circuit on n_qubits qubits.

Return type:

QuantumCircuit

abstractmethod static n_params_per_layer(n_qubits, **kwargs)[source]

Returns the number of parameters required by the ansatz for one layer.

Return type:

int