-
Notifications
You must be signed in to change notification settings - Fork 227
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
Reimplement Clar Optimization with Scipy MILP #2623
Reimplement Clar Optimization with Scipy MILP #2623
Conversation
1. Replace lpsolve APIs with the scipy milp APIs. The new implementation potentially have a slightly better performance (due to vectorization, less data transfer, comparable solver performance, etc.) and improved readability. 2. Decouple the MILP solving step (as _solve_clar_milp ) from the MILP formulation step. The motivation is to avoid unnecessary computation. The original approach includes molecule analysis (specifically `get_aromatic_rings`) into the recursive calls. However, this is not necessary, as molecules are just copied and not modified at all. Therefore analyzing once is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! Do we have a test for the clar optimization to test this part of code?
Co-authored-by: Hao-Wei Pang <45482070+hwpang@users.noreply.github.com>
A worthy goal - thanks for this PR. Removing dependencies is always a good thing! Will removing |
Yes, there's the Clar test covering relevant topics. RMG-Py/test/rmgpy/molecule/resonanceTest.py Line 1367 in 0455970
And by default during the resonance structure generation for PAHs, RMG will also run clar optimization every time. |
Yes. Currently, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Happy to merge it once tests pass.
Blocked by #2553 |
Closing in favor of #2694 |
Motivation or Problem
Clar optimization was originally implemented with lpsolve55, potentially introducing difficulties in maintenance. This PR replaces lpsolve55 with
scipy.optimize.milp
with a hope to alleviate the burden in maintaining this external package.Description of Changes
get_aromatic_rings
) into the recursive calls. However, this is not necessary, as molecules are just copied over and not modified at all. Therefore, analyzing once is enough.Testing
No new tests are added. The replacement expects no failure in previous tests.
Reviewer Tips
A short meeting with me @xiaoruiDong before the reviewing is preferred, which should help the reviewer understand changes.