3
$\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$

1 Answer 1

4
$\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$ Commented May 17, 2021 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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