class UMDA(maxiter=100, size_gen=20, alpha=0.5, callback=None)[source]#

Bases: Optimizer

Continuous Univariate Marginal Distribution Algorithm (UMDA).

UMDA [1] is a specific type of Estimation of Distribution Algorithm (EDA) where new individuals are sampled from univariate normal distributions and are updated in each iteration of the algorithm by the best individuals found in the previous iteration.

See also

This original implementation of the UDMA optimizer for Qiskit was inspired by my (Vicente P. Soloviev) work on the EDAspy Python package [2].

EDAs are stochastic search algorithms and belong to the family of the evolutionary algorithms. The main difference is that EDAs have a probabilistic model which is updated in each iteration from the best individuals of previous generations (elite selection). Depending on the complexity of the probabilistic model, EDAs can be classified in different ways. In this case, UMDA is a univariate EDA as the embedded probabilistic model is univariate.

UMDA has been compared to some of the already implemented algorithms in Qiskit library to optimize the parameters of variational algorithms such as QAOA or VQE and competitive results have been obtained [1]. UMDA seems to provide very good solutions for those circuits in which the number of layers is not big.

The optimization process can be personalized depending on the parameters chosen in the initialization. The main parameter is the population size. The bigger it is, the final result will be better. However, this increases the complexity of the algorithm and the runtime will be much heavier. In the work [1] different experiments have been performed where population size has been set to 20 - 30.


The UMDA implementation has more parameters but these have default values for the initialization for better understanding of the user. For example, lpha parameter has been set to 0.5 and is the percentage of the population which is selected in each iteration to update the probabilistic model.


This short example runs UMDA to optimize the parameters of a variational algorithm. Here we will use the same operator as used in the algorithms introduction, which was originally computed by Qiskit Nature for an H2 molecule. The minimum energy of the H2 Hamiltonian can be found quite easily so we are able to set maxiters to a small value.

from qiskit_algorithms.optimizers import UMDA
from qiskit_algorithms import QAOA
from qiskit.quantum_info import Pauli
from qiskit.primitives import Sampler

X = Pauli("X")
I = Pauli("I")
Z = Pauli("Z")

H2_op = (-1.052373245772859 * I ^ I) +             (0.39793742484318045 * I ^ Z) +             (-0.39793742484318045 * Z ^ I) +             (-0.01128010425623538 * Z ^ Z) +             (0.18093119978423156 * X ^ X)

p = 2  # Toy example: 2 layers with 2 parameters in each layer: 4 variables

opt = UMDA(maxiter=100, size_gen=20)
qaoa = QAOA(Sampler(), opt,reps=p)
result = qaoa.compute_minimum_eigenvalue(operator=H2_op)

If it is desired to modify the percentage of individuals considered to update the probabilistic model, then this code can be used. Here for example we set the 60% instead of the 50% predefined.

opt = UMDA(maxiter=100, size_gen=20, alpha = 0.6)
qaoa = QAOA(Sampler(), opt,reps=p)
result = qaoa.compute_minimum_eigenvalue(operator=H2_op)


This component has some function that is normally random. If you want to reproduce behavior then you should set the random number generator seed in the algorithm_globals (qiskit_algorithms.utils.algorithm_globals.random_seed = seed).


[1]: Vicente P. Soloviev, Pedro Larrañaga and Concha Bielza (2022, July). Quantum Parametric Circuit Optimization with Estimation of Distribution Algorithms. In 2022 The Genetic and Evolutionary Computation Conference (GECCO). DOI:

[2]: Vicente P. Soloviev. Python package EDAspy.

  • maxiter (int) – Maximum number of iterations.

  • size_gen (int) – Population size of each generation.

  • alpha (float) – Percentage (0, 1] of the population to be selected as elite selection.

  • callback (Callable[[int, np.array, float], None] | None) – A callback function passed information in each iteration step. The information is, in this order: the number of function evaluations, the parameters, the best function value in this iteration.


STD_BOUND = 0.3#

Returns the alpha parameter value (percentage of population selected to update probabilistic model)


Returns bounds support level


Returns gradient support level


Returns initial point support level


Returns is bounds ignored


Returns is bounds required


Returns is bounds supported


Returns is gradient ignored


Returns is gradient required


Returns is gradient supported


Returns is initial point ignored


Returns is initial point required


Returns is initial point supported


Returns the maximum number of iterations


Return setting


Returns the size of the generations (number of individuals per generation)



Get the support level dictionary.

static gradient_num_diff(x_center, f, epsilon, max_evals_grouped=None)#

We compute the gradient with the numeric differentiation in the parallel way, around the point x_center.

  • x_center (ndarray) – point around which we compute the gradient

  • f (func) – the function of which the gradient is to be computed.

  • epsilon (float) – the epsilon used in the numeric differentiation.

  • max_evals_grouped (int) – max evals grouped, defaults to 1 (i.e. no batching).


the gradient computed

Return type:


minimize(fun, x0, jac=None, bounds=None)[source]#

Minimize the scalar function.

  • fun (Callable[[POINT], float]) – The scalar function to minimize.

  • x0 (POINT) – The initial point for the minimization.

  • jac (Callable[[POINT], POINT] | None) – The gradient of the scalar function fun.

  • bounds (list[tuple[float, float]] | None) – Bounds for the variables of fun. This argument might be ignored if the optimizer does not support bounds.


The result of the optimization, containing e.g. the result as attribute x.

Return type:



Print algorithm-specific options.


Set max evals grouped


Sets or updates values in the options dictionary.

The options dictionary may be used internally by a given optimizer to pass additional optional values for the underlying optimizer/optimization function used. The options dictionary may be initially populated with a set of key/values when the given optimizer is constructed.


kwargs (dict) – options, given as name=value.

static wrap_function(function, args)#

Wrap the function to implicitly inject the args at the call of the function.

  • function (func) – the target function

  • args (tuple) – the args to be injected



Return type: