• Members 8 posts

I am trying to construct a parametrized circuit in qiskit, or a parametrized QAOA, which means I need to define a list of parameters. Currently I need to construct it one by one using

theta = Parameter('θ')


Is there a more efficient way that I can create $n$ number of parameters?

• Members 4 posts

You can use ParameterVector to create a list of parameters.

from qiskit.circuit import ParameterVector, QuantumCircuit
theta = ParameterVector('θ', 4)
qc = QuantumCircuit(4)
for i in range(4):
qc.rx(theta[i],i)
qc.draw()


Then bind the values:

qc = qc.bind_parameters({theta: [2,3,4,5]})
qc.draw()


image.png

PNG, 14.1 KB, uploaded by BrownB on Oct. 28, 2021.

image.png

PNG, 15.5 KB, uploaded by BrownB on Oct. 28, 2021.

• arrow_forward

Thread has been moved from Quantum Computing Software.