jpmorganchase / QOKit

QOKit
https://www.jpmorgan.com/technology/applied-research
Apache License 2.0
51 stars 23 forks source link

Fix the behavior of maxcut objective with different API #31

Closed rsln-s closed 9 months ago

rsln-s commented 10 months ago

Adding a test confirming that terms and precomputed objective give the same result

rajgane07 commented 10 months ago

@rsln-s @gromitsun

I made change accommodate sign change based on a parameter. This I feel is more robust and requires just one time change for 'minimization' and 'maximization' problems. This does not affect LABS code, and can be refactored according to this design. if you guys satisfied with this do not approve, I will make changes for terms to be converted to diagonal upfront.

rajgane07 commented 10 months ago

@rsln-s - I have updated qaoa_objective_maxcut.py to calculate precomputed_diagonal_hamiltonian upfront for terms too.

rajgane07 commented 9 months ago

I have updated the code in qaoa_objective.py for qiskit simulator to call precompute_vectorized_cpu_parallel to get precomputed energies and removed precompute_terms function

rajgane07 commented 9 months ago

@rsln-s Since yesterday I am trying to debug why black is failing for a file I did not change in the Action. Black check works without any issues on both my LVDI and my Mac Laptop. However all test cases passes and code is running as expected. Can you please try at your end by pushing the portfolio_optimization.py file?

rsln-s commented 9 months ago

Hey @rajgane07, I believe it was a black versioning issue. Bumping black version to 24.1a1 (pip install -U black==24.1a1) solved it (see 5a1967d). On my Mac, by default pip install black installs black-23.12.1, which appears to behave differently.

rajgane07 commented 9 months ago

@rsln-s - Thanks for the upate. I think all the Actions are green (except documentation). Can you please review and merge the code? I would like to take the latest to work on next issue