qaoa: var assignment mode#419
qaoa: var assignment mode#419Milos9304 wants to merge 2 commits intoeclipse-xacc:masterfrom Milos9304:dev_assignment_mode
Conversation
Signed-off-by: Milos9304 <prokop.milos@gmail.com>
Signed-off-by: Milos9304 <prokop.milos@gmail.com>
|
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. |
|
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 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. |
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?