Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
Merge e88f7de into 2e1ba88
Browse files Browse the repository at this point in the history
  • Loading branch information
yaelbh committed Jan 30, 2020
2 parents 2e1ba88 + e88f7de commit 9391a81
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion qiskit/aqua/algorithms/adaptive/vqe/vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from typing import Optional, List, Callable
import logging
import functools
from time import time

import numpy as np
from qiskit import ClassicalRegister, QuantumCircuit
Expand Down Expand Up @@ -333,20 +334,27 @@ def _build_parameterized_circuits():
circuits.append(circuit)
to_be_simulated_circuits = functools.reduce(lambda x, y: x + y, circuits)

start_time = time()
result = self._quantum_instance.execute(to_be_simulated_circuits,
self._parameterized_circuits is not None)
end_time = time()
logger.info('Circuits execution - %.5f (ms)',
(end_time - start_time) * 1000)

for idx, _ in enumerate(parameter_sets):
start_time = time()
mean, std = self._operator.evaluate_with_result(
result=result, statevector_mode=self._quantum_instance.is_statevector,
use_simulator_snapshot_mode=self._use_simulator_snapshot_mode,
circuit_name_prefix=str(idx))
end_time = time()
mean_energy.append(np.real(mean))
std_energy.append(np.real(std))
self._eval_count += 1
if self._callback is not None:
self._callback(self._eval_count, parameter_sets[idx], np.real(mean), np.real(std))
logger.info('Energy evaluation %s returned %s', self._eval_count, np.real(mean))
logger.info('Energy evaluation %s returned %s - %.5f (ms)',
self._eval_count, np.real(mean), (end_time - start_time) * 1000)

return mean_energy if len(mean_energy) > 1 else mean_energy[0]

Expand Down

0 comments on commit 9391a81

Please sign in to comment.