joshlk / k-means-constrained

K-Means clustering - constrained with minimum and maximum cluster size. Documentation: https://joshlk.github.io/k-means-constrained
https://github.com/joshlk/k-means-constrained
BSD 3-Clause "New" or "Revised" License
192 stars 43 forks source link

[BUG] Incompatible with `ortools >= 9.4` (`No module named 'ortools.graph.pywrapgraph'`) #28

Closed esmail closed 2 years ago

esmail commented 2 years ago

Describe the bug k-means-constrained is incompatible with ortools version 9.4+

Minimum working example from k_means_constrained import KMeansConstrained

Results in:

...
    from k_means_constrained import KMeansConstrained
  File "/home/ubuntu/hbx/python/lib/python3.8/site-packages/k_means_constrained/__init__.py", line 4, in <module>
    from .k_means_constrained_ import KMeansConstrained
  File "/home/ubuntu/hbx/python/lib/python3.8/site-packages/k_means_constrained/k_means_constrained_.py", line 29, in <module>
    from k_means_constrained.mincostflow_vectorized import SimpleMinCostFlowVectorized
  File "/home/ubuntu/hbx/python/lib/python3.8/site-packages/k_means_constrained/mincostflow_vectorized.py", line 4, in <module>
    from ortools.graph.pywrapgraph import SimpleMinCostFlow
ModuleNotFoundError: No module named 'ortools.graph.pywrapgraph'

Versions:

lperron commented 2 years ago

Please replace ortools.graph.pywrapgraph by ortools.graph.python.min_cost_flow.

lperron commented 2 years ago

The good news is that it now supports numpy to speed-up the creation of the graph.

See this example.

datatravelgit commented 2 years ago

Please replace ortools.graph.pywrapgraph by ortools.graph.python.min_cost_flow.

As far as I my test goes, this is not sufficient. Other imports may need to be changed to adapt to or tools >=9.4

lperron commented 2 years ago

ortools.graph.pywrapgraph has been split in 3.

See https://github.com/google/or-tools/releases/tag/v9.4

Le lun. 29 août 2022, 12:26, Data Travel @.***> a écrit :

Please replace ortools.graph.pywrapgraph by ortools.graph.python.min_cost_flow.

As far as I my test goes, this is not sufficient. Other imports may need to be changed to adapt to or tools >=9.4

— Reply to this email directly, view it on GitHub https://github.com/joshlk/k-means-constrained/issues/28#issuecomment-1230096232, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3M27NHMIDM2IXFNAUTV3SF43ANCNFSM56SQBD2A . You are receiving this because you commented.Message ID: @.***>

joshlk commented 2 years ago

The issue should be resolved with the latest version. Please update the package using pip install 'k-means-constrained>=0.7.2' and report back

lcustodio commented 2 years ago

New version is working fine for me 👍

joshlk commented 2 years ago

Great. I’ll close this for now. Let me know if you have any more issues

datatravelgit commented 2 years ago

Just tested. All ok on my side as well. Thanks

lperron commented 2 years ago

Thanks for the rapid fix.