Skip to content

Commit bd81f6e

Browse files
committed
Refoctored aqt example file in order to limit the max_shots value (AQT limits at 2000 max).
1 parent 8f7aaa2 commit bd81f6e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

examples/run_aqt_estimator.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import math
1415
from scipy.optimize import minimize
1516

1617
from qiskit import QuantumCircuit
@@ -63,8 +64,13 @@ def cost_function(
6364
Return the estimated expectation value of the Hamiltonian
6465
on the state prepared by the Ansatz circuit.
6566
"""
67+
max_shots = 100
68+
precision = 1 / math.sqrt(max_shots - 1)
69+
6670
return float(
67-
estimator.run([(ansatz, hamiltonian, params)]).result().values[0]
71+
estimator.run([(ansatz, hamiltonian, params)], precision=precision)
72+
.result()[0]
73+
.data["evs"]
6874
)
6975

7076

0 commit comments

Comments
 (0)