Skip to content
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

[Python 3.9] Reimplement Clar Optimization with Scipy MILP #2694

Draft
wants to merge 105 commits into
base: feat/py39
Choose a base branch
from

Conversation

JacksonBurns
Copy link
Contributor

This PR replaces #2623 as discussed in this comment: #2687 (comment)

ChrisBNEU and others added 16 commits May 17, 2024 15:36
added per sevy's review

Co-authored-by: Sevy Harris <[email protected]>
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.
@JacksonBurns
Copy link
Contributor Author

Command to run the tests related to this PR:

python-jl -m pytest \
test/rmgpy/data/solvationTest.py::TestSoluteDatabase::test_saturation_density \
test/rmgpy/data/thermoTest.py::TestCyclicThermo::test_add_poly_ring_correction_thermo_data_from_heuristic_using_pyrene \
test/rmgpy/data/thermoTest.py::TestMolecularManipulationInvolvedInThermoEstimation::test_bicyclic_decomposition_for_polyring_using_pyrene \
test/rmgpy/data/kinetics/familyTest.py::TestTreeGeneration::test_f_rules \
test/rmgpy/data/kinetics/familyTest.py::TestTreeGeneration::test_d_regularization_dims \
test/rmgpy/molecule/moleculeTest.py::TestMolecule::test_count_aromatic_rings \
test/rmgpy/molecule/resonanceTest.py::ResonanceTest::test_naphthyl \
test/rmgpy/molecule/resonanceTest.py::ResonanceTest::test_methyl_napthalene \
test/rmgpy/molecule/resonanceTest.py::ResonanceTest::test_methyl_phenanthrene \
test/rmgpy/molecule/resonanceTest.py::ResonanceTest::test_methyl_phenanthrene_radical \
test/rmgpy/molecule/resonanceTest.py::ResonanceTest::test_c13h11_rad \
test/rmgpy/molecule/resonanceTest.py::ResonanceTest::test_aryne_3_rings \
test/rmgpy/molecule/resonanceTest.py::ResonanceTest::test_polycyclic_aromatic_with_non_aromatic_ring2 \
test/rmgpy/molecule/resonanceTest.py::ResonanceTest::test_false_negative_polycyclic_aromaticity_perception \
test/rmgpy/molecule/resonanceTest.py::ResonanceTest::test_false_negative_polycylic_aromaticity_perception2 \
test/rmgpy/molecule/resonanceTest.py::ClarTest::test_clar_optimization \
test/rmgpy/molecule/resonanceTest.py::ClarTest::test_phenanthrene \
test/rmgpy/molecule/resonanceTest.py::ClarTest::test_phenalene \
test/rmgpy/molecule/resonanceTest.py::ClarTest::test_corannulene \
test/rmgpy/statmech/ndTorsionsTest.py::TestHinderedRotorClassicalND::test_hindered_rotor_nd

@JacksonBurns
Copy link
Contributor Author

Notes about install:

@JacksonBurns
Copy link
Contributor Author

Didn't work

../../../miniconda3/envs/rmg_env/lib/python3.9/site-packages/rdkit/Chem/__init__.py:16: in <module>
    from rdkit.Chem import rdchem
E   ImportError: /home/runner/miniconda3/envs/rmg_env/lib/python3.9/site-packages/scipy/sparse/../../../../libstdc++.so.6: version `GLIBCXX_3.4.31' not found (required by /home/runner/miniconda3/envs/rmg_env/lib/python3.9/site-packages/rdkit/Chem/../../../../libboost_serialization.so.1.86.0)
@JacksonBurns
Copy link
Contributor Author

May need to downgrade julia back to 1.8 or something like that: #2353 (comment)

@JacksonBurns
Copy link
Contributor Author

@rwest @mjohnson541 I am trying to get the Python 3.9 + PythonCall overhaul working - repeatedly running into something like:

ERROR: InitError: Python: ImportError: /home/runner/miniconda3/envs/rmg_env/.julia/juliaup/julia-1.9.4+0.x64.linux.gnu/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.31' not found (required by /home/runner/miniconda3/envs/rmg_env/lib/python3.9/site-packages/rdkit/Chem/../../../../libboost_serialization.so.1.86.0)

during test startup. Any ideas?

@mjohnson541
Copy link
Contributor

It looks like this issue here: https://discourse.julialang.org/t/glibcxx-version-not-found/82209/7

There's a fix that looks promising a few responses down...they write it in terms of CondaPkg.jl, but if we constrain libstdcxx-ng properly in the environment file it should do the same thing.

@JacksonBurns
Copy link
Contributor Author

Great find, thanks! We actually don't have libstdcxx in the environment file because that package only exists for linux (at least, on conda-forge). Any ideas to keep Mac compat?

@mjohnson541
Copy link
Contributor

Hmm...possibilities that occur to me:

  1. Build a simple conda metapackage that controls that dependency so it is applied in linux, but not in mac: https://docs.conda.io/projects/conda-build/en/latest/resources/commands/conda-metapackage.html
  2. Split the environment file between mac/linux again

@JacksonBurns
Copy link
Contributor Author

Those both seem like good options, will consider once this gets closer to merging.

Latest errors are the same as before (without attempting to limit the library version). I am going to roll in the changes from #2631 and try to get this running without Julia to start with, since I think there is a possible library incompatibility problem with RDKit and SciPy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants