-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix GroverOptimizer's rotation_count #132
Conversation
m
LGTM! The code |
A question is still left. A function As a conclusion, we need overhaul |
* Simpify GroverOptimizer._measure * Simplify unit tests of GroverOptimizer
Looking at the coverage output from CI here, |
I see. We should add a unit test of |
I would have imagined that is_good_state should have been called by Grover during its normal operation. As such I am unsure why coverage shows that its not called - and your comment above indicated its not called since even with parameters mismatching on the signature it should get called, but may go wrong/exception. Does this need further investigation? |
Yes, we need further investigation about is_good_state in a separate issue. Since it does not seem to affect the existing unit tests, I think we can merge this PR. |
* Fix rotation_count in GroverOptimizer * Simpify GroverOptimizer._measure * Simplify unit tests of GroverOptimizer (cherry picked from commit b0d411a) # Conflicts: # qiskit_optimization/algorithms/grover_optimizer.py # test/algorithms/test_grover_optimizer.py
Summary
Fixes #129
GroverOptimizer's rotation_count is set in a wrong way.
It is originally
rotation_count = int(np.ceil(algorithm_globals.random.uniform(0, m - 1)))
, but it is always 1 ifm=1
.It should be either 0 or 1. So, I replace it with
algorithm_globals.random.integers(0, m)
.The order of
result.get_counts(qc)
has an issue. It is sorted by probability, but some bitstrings may have the same probabilities and it results in a probabilistic behavior of unit tests on different environment (mac and linux).This PR sorts the counts by bitstring order if qasm_simulator is used. So, the resulting iterator has the same order in any environment.
If statevector_simulator is used, it omits the sort because the results are generated in a sorted order.
Details and comments