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

qaoa: var assignment mode #419

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

qaoa: var assignment mode #419

wants to merge 2 commits into from

Conversation

Milos9304
Copy link

m_varAssignmentMode: Determines the optimal configuration found by the qaoa, not only the optimal value as before. This can be handy for many optimization problems where we do not only seek the optimal value, but we are interested in the solution as well.

Had to edit Accelerator.hpp (see code) as the number of shots needs to be adjusted during the run of the qaoa algorithm before the var_assignment_mode routine starts. It would be good to think about a better way to adjust parameters of accelerators during run of the program. Is there any reason it has not been implemented yet?

@gitpod-io
Copy link

gitpod-io bot commented Apr 1, 2021

@amccaskey
Copy link
Contributor

Hey @Milos9304 thanks for this contribution! I've finally got a bit of time to review it. I'm a bit confused about what you are trying to accomplish. Perhaps you can provide a bit more of a description about your use case.

It is true that if you run with an Accelerator without shots set, then you'll only get expectation values on the cost function. If you then run with a shots-enabled Accelerator you'll get a bit-count dictionary that you could use. As for updating the shots on a given Accelerator, we have the updateConfiguration() method that you could use instead of adding another method to Accelerator.

@Milos9304
Copy link
Author

Thx @amccaskey, I'm happy to explain. Perhaps I confused you with the terminology I used, I apologize, because what I am trying to achieve is really simple. E.g. for maxcut problem, xacc is currently able to find the maximum cut value but not the partition of graph nodes into two sets which requires sampling the ansatz measurements with the optimal ansatz parametes found. In qiskit for example you run

qaoa_result = qaoa.solve(qubo)
print(qaoa_result)

with output

optimal function value: -2.0
optimal value: [0. 1. 0.]
status: SUCCESS

What I aim to achieve is the optimal_value which returns the found solution to the given qubo, or more precisely in our case(since xacc does not work with qubo formulations, but we directly specify problem hamiltonians) we determine the computational basis state corresponding to lowest eigenvalue of the problem hamiltonian.

And thanks for the updateConfiguration suggestion, I missed that. I'll update my code.

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.

2 participants