Adds translators between modeling libraries and quadratic program#122
Adds translators between modeling libraries and quadratic program#122manoelmarques merged 68 commits intoqiskit-community:mainfrom
Conversation
|
I notice that we may be able to simplify |
# Conflicts: # qiskit_optimization/problems/quadratic_program.py
|
I have updated unit tests and tutorials so that everything uses the new |
|
I created an Issue in Finance - and linked it as you can see here above - since the docplex based applications there should be updated to make them compatible with this change. |
|
I'm not sure why sphinx-spelling reports "October" is misspelling. But, I add it to pylintdict to pass CI, anyways.
|
|
As for having some template for deprecation msgs that @woodsp-ibm mentioned. I had created a set of methods in Qiskit-Aqua at https://github.com/Qiskit/qiskit-aqua/blob/main/qiskit/aqua/deprecation.py. I will create something similar to be used by the application projects. |
|
Thank you. I fixed the deprecation message following @woodsp-ibm's advice. If your template is merged before the review of this PR, I use it. |
|
@t-imamichi If you intend to finish this PR before Monday, feel free to do it. I will be looking at this template on Monday and looking at all repo usages so that it applies to everything. It may not be ready before you finish this PR. If your PR is already merged, I will change the code to use the template methods. |
|
I have finished the revision of PR just now. I need to wait for review. |
|
Looks good but one final thing. If you look in the combined deprecation output in CI there are 4 warnings being emitted related to to/from docplex. Maybe these are from unit tests but I can't tell. I think normally we would have If these warnings are from unit tests, normally there in the test we suppress and re-enable the warning around the code that we know will emit it so we don't end up seeing these anymore in CI. This is as ideally we should not be emitting deprecation warnings, by using Qiskit code, whether from other modules or tutorials, when we release. So avoiding warnings appearing from unit tests helps keep the log clean and easier to deal with the main code - now there are some warnings from 3rd party libraries, these are usually unavoidable until the library itself updates. |
|
OK. The deprecation message was due to the unit test |
|
Ok, normally we continue to test deprecated function while it exists to make sure it continues to work while we support it, ahead of its removal, but then suppress the deprecation warning around the test code as we know calling it will emit a warning. Anyway in this case I guess the risk is small in having no test coverage since the methods just simply call across to code that is tested. It would be good even so though on the warnings.warn calls to have stacklevel=2 set so the site of where its called from is shown in the messages, otherwise it shows the function itself which can make it hard to find/know where its being called from. |
This reverts commit 958726a.
|
I see. It is safer to keep |
…arning in a unit test
woodsp-ibm
left a comment
There was a problem hiding this comment.
I think we are good to go now. @t-imamichi thanks!
Summary
Revised version of #116.
It introduces a model translators to convert a modeling libraries (e.g., docplex, gurobipy, etc.) to
QuadraticProgramand vice versa.It adds
qiskit_optimization.translatorsdirectory and the following functions are implemented.from_docplex_mpto_docplex_mpfrom_gurobipyto_gurobipyBecause I plan to implement
docplex.cpversion of translators in the future, I use the namedocplex_mpinstead of justdocplex.Fixes #80
TODO
QP.from_docplexorQP.to_docplex.QP.from_docplexorQP.to_docplex.Details and comments
Deprecations
QuadraticProgram.from_docplex: will be replaced withfrom_docplex_mp.QuadraticProgram.to_docplex: will be replaced withto_docplex_mpRemoval
QuadraticProgram.{pprint_as_string,prettyprint}: they were deprecated in aqua as mentioned Adds translators between modeling libraries and quadratic program #122 (comment)