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

Expose brute force solver through OpenQAOA workflows #234

Closed
2 tasks done
vishal-ph opened this issue May 17, 2023 · 10 comments · Fixed by #246
Closed
2 tasks done

Expose brute force solver through OpenQAOA workflows #234

vishal-ph opened this issue May 17, 2023 · 10 comments · Fixed by #246
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@vishal-ph
Copy link
Collaborator

Prerequisites

Before raising this feature request, I made sure:

  • It does not lead to duplication.
  • It has not already been requested.

Is your feature request related to a problem? Please describe.

OpenQAOA has a function called ground_state_hamiltonian that takes as input the Cost Hamiltonian corresponding to the QUBO problem and outputs the degenerate solutions (or ground states of the Hamiltonian) along with the lowest energy (i.e. ground state energy). The function is defined in src/openqaoa-core/openqaoa/utilities.py.

Expose this function as a QAOA workflow class method so users can easily access it.

Describe the solution you'd like

  • Implement the method that calls this function from within the QAOA workflow class
  • Make sure to impose an artificial limit on the size of problem (in terms of the number of qubits) to prevent memory overflow.

Ideal workflow

  1. q = QAOA()
  2. q.compile(qubo)
  3. q.solve_brute_force()

Describe alternatives you've considered

The existing way to obtain the brute force solution of a qubo is described as follows:

  1. construct the problem qubo
  2. `from openqaoa.utilities import ground_state_hamiltonian
  3. Construct the hamiltonian object by calling prob_hamiltonian = qubo.hamiltonian
  4. Obtain the solution solution, energy = ground_state_hamiltonian(prob_hamiltonian)
@vishal-ph vishal-ph added enhancement New feature or request good first issue Good for newcomers unitary_fund A feature supported by an UF grant and removed unitary_fund A feature supported by an UF grant labels May 17, 2023
@lumapools
Copy link

lumapools commented May 26, 2023

Hi, I have attempted to implement the brute_force method as well as added some unit tests, could you please assign me to this issue?

@vishal-ph
Copy link
Collaborator Author

@lumapools, just did! Thanks

@lumapools
Copy link

Thank you! Just created the PR with the feature and new tests to be added

@Q-lds
Copy link
Member

Q-lds commented Jun 1, 2023

We currently have 2 PRs addressing this issue:

What I'd propose is to merge the two PRs and share the bounty. I like the implementation of the function from @GiacomoFrn , and @lumapools nicely added some tests. So, maybe we can take the solution from 239 and then add the (updated) tests from 240. What do you guys say? Could this be a fair solution? :)

@GiacomoFrn
Copy link
Contributor

Seems a fair solution to me! It was my first open source contribution and I didn't know I was supposed to add tests, @lumapools instead did it.

@lumapools
Copy link

lumapools commented Jun 1, 2023

I think it is a good idea too! How should we go about merging ? Should we first merge @GiacomoFrn 's PR and then I modify my PR (or close it to create a new one) to only include the (new) tests for @GiacomoFrn 's code ?

@Q-lds
Copy link
Member

Q-lds commented Jun 1, 2023

Perfect!

@vishal-ph I think we follow @lumapools suggestion. What do you think?

Q-lds added a commit that referenced this issue Jun 5, 2023
Partial hotfix of issue #234: Brute force solver as OpenQAOA workflow class method
@vishal-ph vishal-ph linked a pull request Jun 7, 2023 that will close this issue
1 task
@vishal-ph
Copy link
Collaborator Author

thanks @lumapools, @GiacomoFrn for contributing to OpenQAOA and helping solve this issue!

@GiacomoFrn
Copy link
Contributor

@vishal-ph , @Q-lds I believe I also should be assigned to the issue in order to follow the regulation of the unitaryHack and get part of the bounty

@Q-lds
Copy link
Member

Q-lds commented Jun 13, 2023

@GiacomoFrn I have added you as well. Hope this fixes it! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants