Skip to content
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

GroverOptimizer with Sampler #437

Closed

Conversation

a-matsuo
Copy link
Contributor

@a-matsuo a-matsuo commented Nov 15, 2022

Summary

Add support of Sampler to GroverOptimizer

Addresses #425

  • update codes
  • update tests
  • update docs
  • add reno

Details and comments

@t-imamichi
Copy link
Collaborator

Thank you, @a-matsuo. I'm thinking of integrating this PR to #436.

@a-matsuo
Copy link
Contributor Author

Sure, I'm fine with it. Let me finalize the codes.

@@ -54,6 +57,7 @@ def __init__(
Union[QuadraticProgramConverter, List[QuadraticProgramConverter]]
] = None,
penalty: Optional[float] = None,
sampler: Optional[BaseSampler] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At one point I thought there had been discussion about changing things here so it used the Grover algorithm from Terra - I thought it was now possible since this was done long ago and the Grover implementation since then had become more capable where this could be done. Maybe as an alternate new path, while keeping the old more direct code this is more complex to achieve this time around - i.e. instead of a Sampler it would take a Grover (which itself would already be setup with a Sampler).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the reviewing. I agree with that it is nice to use the Grover class in Terra. I believe it's possible since the Grover class can receive functions for iteration and is_good_state. So, we can dynamically change the iteration of the Grover operator in the algorithm by squashing the current code into iteration and is_good_state. (This might be a good issue for the qiskit advocate mentorship program. I don't have time right now. )

For GroverOptimizer, we need to change the variables of Grover dynamically. So, we can pass something like Grover(quantum_instance=quantum_instance) or Grover(sampler=sampler), but this doesn't make much difference, and I think passing a sampler looks better than passing Grover(sampler=sampler) to me.

@a-matsuo a-matsuo marked this pull request as ready for review November 17, 2022 02:20
@a-matsuo a-matsuo changed the title [WIP] GroverOptimizer with Sampler GroverOptimizer with Sampler Nov 17, 2022
@t-imamichi
Copy link
Collaborator

Since this PR is based on #436, I will merge this PR to #436.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3484791344

  • 100 of 108 (92.59%) changed or added relevant lines in 7 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.09%) to 92.104%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit_optimization/algorithms/optimization_algorithm.py 18 19 94.74%
qiskit_optimization/deprecation.py 1 2 50.0%
qiskit_optimization/algorithms/grover_optimizer.py 48 54 88.89%
Files with Coverage Reduction New Missed Lines %
qiskit_optimization/algorithms/grover_optimizer.py 1 94.26%
qiskit_optimization/runtime/vqe_program.py 1 96.67%
Totals Coverage Status
Change from base Build 3482657244: -0.09%
Covered Lines: 4374
Relevant Lines: 4749

💛 - Coveralls

@t-imamichi
Copy link
Collaborator

t-imamichi commented Nov 18, 2022

I have merged it to #436. So, I close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants