Add maximize to minimize converter#114
Conversation
Many algorithms converted problems internally to minimization. To avoid duplicate code MaximizeToMinimize converter is used now. Since the internal problem is now minimization, there are changes to the following results: - intermediate_fval in GroverOptimizationResult is that of the minimization QUBO. - raw_results in OptimizationResult are those of the the minimization QUBO. - ADMM optimizer logs out the minimization objective values samples in OptimizationResult are still that of the original problem. This solves issue qiskit-community#41
|
The installation of cvxpy by just using pip install qiskit-optimization[cvxpy] was not enough to set up the complete test on my local machine and I missed to check whether the tests were still skipped. Sorry for that. I have checked the failed Unit Test: TestWarmStartQAOAOptimizer.test_max_cut optimal function value: 0.0 Instead of This leads to a wrong result. Maybe we should not add MaximizeToMinimize always to the default converters list in https://github.com/Qiskit/qiskit-optimization/blob/3e21815034c72030eab17f2865895dc0d12076a4/qiskit_optimization/algorithms/optimization_algorithm.py#L354 Then, we can alter the UnitTest to use a fixed List of converters(without MaximizeToMinimize) instead of the default list. Maybe GoemansWilliamsonOptimizer should give a hint if it is used with a minimization problem? |
woodsp-ibm
left a comment
There was a problem hiding this comment.
Nice job for a first contribution! You have even done a reno yaml file, nice!
|
Could you apply black code formatter by |
Use black formatter Solve conflicts: qiskit_optimization/algorithms/admm_optimizer.py qiskit_optimization/algorithms/grover_optimizer.py qiskit_optimization/algorithms/minimum_eigen_optimizer.py qiskit_optimization/algorithms/multistart_optimizer.py qiskit_optimization/algorithms/optimization_algorithm.py qiskit_optimization/algorithms/slsqp_optimizer.py test/converters/test_converters.py
|
Sorry. Could format again by |
|
I think we need to simplify each algorithm to use both For example, ADMM case |
Hello @t-imamichi , |
Solve conflicts: qiskit_optimization/algorithms/grover_optimizer.py test/algorithms/test_min_eigen_optimizer.py
adekusar-drl
left a comment
There was a problem hiding this comment.
One thing to check out is the warm start QAOA test. Other than that, looks good to me! Thanks a lot!
Co-authored-by: Takashi Imamichi <31178928+t-imamichi@users.noreply.github.com>
|
Let's see the CI result. I think this PR is ready if CI passes. |
t-imamichi
left a comment
There was a problem hiding this comment.
Thank you for your cooperation! LGTM.
Summary
Adds Maximize To Minimize converter
Fixes #41
Details and comments
Introduces a new converter class
MaximizeToMinimizeforQuadraticProgramas described in #41 .It converts a problem to a minimization problem. The converter is in the default converters list of
OptimizationAlgorithm. Algorithms andQuadraticProgramToQuboare now usingMaximizeToMinimize.