2
$\begingroup$

How can I make intervals for free parameters when I use VQE function? (https://qiskit.org/documentation/stubs/qiskit.algorithms.VQE.html)

I have built a parametrized ($\theta_1,...,\theta_n$) circuit without using ansatz in Qiskit Circuit Library and I would like to set e.g. $\theta_i \in \left[0,\pi\right]$.

$\endgroup$
3
$\begingroup$

You can set the attribute parameters_bounds of a circuit to the desired intervals like below:

from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
a=Parameter('a')
b=Parameter('b')
ansatz=QuantumCircuit(2)
ansatz.ry(a,0)
ansatz.ry(b,1)
ansatz.parameter_bounds=[[0,np.pi]]*2 

Then you can run your vqe program.

$\endgroup$
1
  • $\begingroup$ Perfect, thank you so much. $\endgroup$ – Antonio Anna Mele May 17 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.