# Extended parametrization¶

The `ExtendedParams`

class implements the most general form of the QAOA where each operator in both the cost and mixer Hamiltonians has its own angle.
For example, for a depth-1 (p=1) circuit the unitary operator corresponding to the QAOA circuit would now take the form:

Number of parameters

The number of parameters will depend on the number of edges and biases. In the worst case for a fully connected graph with biases on each node, the optimizer will have to find \((n(n-1) + n + n) p\) parameters.

Let us look again at the simple example of a classical cost hamiltonian on 3 qubits which we used to explain the standard parametrization:

This time, however, the extended parametrization allows us to specify a different angle for every gate with the following:

```
q = QAOA()
q.set_circuit_properties(p=1,
param_type='extended',
init_type='custom',
variational_params_dict={
'gammas_pairs':[1.1, 1.2, 1.3],
'gammas_singles':[2.1, 2.2, 2.3],
'betas_pairs': [],
'betas_singles': [3.1, 3.2, 3.3]}
)
```

As a circuit, this `custom`

initialization looks like:

The rotation angles are still obtained by multiplying the weights with the gamma pair or single and the biases with the beta single. In particular, rotating the second qubit around the Z axis at an angle of 15.4 comes from multiplying the bias of the second qubit, 3.5 in this case, with the second initial parameter in the gammas_singles as specified above, 2.2: 15.4 = 3.5 * 2.2 * 2 where the last 2 is from the convention on how we write gates and angles.

When do we need `beta_pairs`

?

`betas_pairs`

will be relevant only for 2-qubit mixer hamiltonians, for example the XY mixer as implemented by the `XY_mixer_hamiltonian`

in openqaoa-core/utilities.py. If not required, it can be omitted when specifying the initial values altogether.

Overall, this is the most versatile ansatz one can implement while still obeying the fundamental QAOA gate structure. However, this is also the hardest to optimize due to the larger number of variational parameters.

For the curious

It is important to realize that the gate angles can be different also without using the extended parametrization if the weights and biases of the Hamiltonian are different for each term. What the extended parametrization allows is varying each parameter during the classical optimization procedure.