qrisp.vqe.VQEProblem.train_function#
- VQEProblem.train_function(qarg, depth, mes_kwargs={}, max_iter=50, init_type='random', init_point=None, optimizer='COBYLA')[source]#
This function allows for training of a circuit with a given instance of a
VQEProblem
. It will then return a function that can be applied to a QuantumVariable, such that it prepares the ground state of the problem Hamiltonian. The function therefore applies a circuit for the problem instance with optimized parameters.- Parameters:
- qargQuantumVariable
The argument to which the VQE circuit is applied.
- depthint
The amount of VQE layers.
- mes_kwargsdict, optional
The keyword arguments for the
get_measurement
function. Default is an empty dictionary. By default, the targetprecision
is set to 0.01. Precision refers to how accurately the Hamiltonian is evaluated. The number of shots the backend performs per iteration scales quadratically with the inverse precision.- max_iterint, optional
The maximum number of iterations for the optimization method. Default is 50.
- init_typestring, optional
Specifies the way the initial optimization parameters are chosen. Available is
random
. The default israndom
: Parameters are initialized uniformly at random in the interval \([0,\pi/2)]\).- init_pointlist[float], optional
Specifies the initial optimization parameters.
- optimizerstr, optional
Specifies the optimization routine. Available are, e.g.,
COBYLA
,COBYQA
,Nelder-Mead
. The Default is “COBYLA”.
- Returns:
- circuit_generatorfunction
A function that can be applied to a QuantumVariable, with optimized parameters for the problem instance. The QuantumVariable then represents the ground state of the problem Hamiltonian.