Commit 64610aa
Migrate from cbcbox to mipster for the bundled CBC library (#424)
* Migrate from cbcbox to mipster for the bundled CBC library
cbcbox shipped CBC source builds; mipster (https://pypi.org/project/mipster/)
ships self-contained, hardware-tuned wheels for Linux x86_64/aarch64,
macOS x86_64/arm64, and Windows x86_64 with CPUID auto-dispatch
(generic / AVX2 / Haswell / NEON variants).
- Replace `cbcbox>=2.929` with `mipster>=0.2.0`.
- Use `mipster.lib_path()` instead of platform-specific path joining;
this returns the right shared library for the current OS and
selected variant.
- Drop the manual libCbc.so / libCbc-0.dll / libCbc.dylib branching.
- Keep `os.add_dll_directory()` on Windows so the loader can find the
sibling MinGW runtime DLLs that mipster bundles next to libmipster-N.dll.
- Remove unused Cbc_get/setAllowablePercentageGap CFFI declarations
(these are not exported by libmipster and were never called).
* chore: require mipster>=0.2.4
Version 0.2.4 fixes three C API bugs required for correctness:
- Auto-generate column names so translate() works in lazy callbacks
- Sync bound==value when proven optimal (prevents spurious assertion failures)
- Restore rSlk/rActv pointers after MIP solve (prevents null-pointer crash)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* style: apply black formatting
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* style: apply black 22.3.0 formatting (matching pre-commit config)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: gracefully disable HiGHS on Windows when C API is not accessible
highspy's _core.pyd on Windows only exports the Python init symbol
(PyInit__core) -- the C API functions like Highs_create are compiled
in but not exported as DLL symbols. On Linux/macOS all symbols in a
shared library are visible, so ffi.dlopen() works there.
After loading the library via ffi.dlopen(), test whether Highs_create
is actually accessible. If not (Windows + highspy), set has_highs=False
so that all HiGHS tests are skipped gracefully instead of crashing with
'function/symbol not found' errors.
Users on Windows who need HiGHS can install highsbox (which ships a
proper highs.dll with exported C symbols) and set PMIP_HIGHS_LIBRARY
to point to it.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: use highsbox as fallback for HiGHS C API on Windows
highspy's _core.pyd on Windows does not export C symbols (only PyInit_*
is exported from a Windows DLL by default). On Linux/macOS the .so
exports all symbols so ffi.dlopen + Highs_create works fine; on Windows
it raises AttributeError.
Changes:
- After dlopen succeeds, probe Highs_create accessibility. If it fails
(Windows + highspy), automatically retry with highsbox's highs.dll.
- highsbox is added as a Windows-only optional dependency in [highs]:
highsbox>=1.9.0; sys_platform == 'win32'
so 'pip install mip[highs]' on Windows installs both highspy (Python
bindings) and highsbox (C API DLL), giving full HiGHS functionality.
- Hoist the highsbox path resolver to a module-level helper function
_get_highsbox_libfile() so it is reachable both at initial load and
at the fallback probe point.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* ci: cancel in-progress runs when new commit is pushed
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: guard __del__ against partially-constructed objects (PyPy safe)
On PyPy, the GC may call __del__ on an object whose __init__ raised
before all attributes were set (e.g. SolverGurobi.__init__ raises early
when Gurobi is not installed, before _ownsModel/_venv_loaded are set).
CPython avoids this because reference-counting drops the object
immediately; PyPy's tracing GC processes it later.
Replace bare attribute access in __del__ with getattr(..., default) in:
- SolverGurobi.__del__: guard _ownsModel and _venv_loaded
- SolverHighs.__del__: guard _model (avoid calling Highs_destroy(NULL))
- SolverCbc.__del__: guard _model (avoid calling Cbc_deleteModel(NULL))
- SolverOsi.__del__: guard owns_solver
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 3f03388 commit 64610aa
5 files changed
Lines changed: 163 additions & 121 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
93 | 83 | | |
94 | 84 | | |
95 | 85 | | |
96 | 86 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | 87 | | |
104 | 88 | | |
105 | 89 | | |
| |||
317 | 301 | | |
318 | 302 | | |
319 | 303 | | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | 304 | | |
326 | 305 | | |
327 | 306 | | |
| |||
1022 | 1001 | | |
1023 | 1002 | | |
1024 | 1003 | | |
1025 | | - | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
1026 | 1007 | | |
1027 | 1008 | | |
1028 | 1009 | | |
| |||
1203 | 1184 | | |
1204 | 1185 | | |
1205 | 1186 | | |
1206 | | - | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
1207 | 1190 | | |
1208 | 1191 | | |
1209 | 1192 | | |
| |||
1662 | 1645 | | |
1663 | 1646 | | |
1664 | 1647 | | |
1665 | | - | |
| 1648 | + | |
| 1649 | + | |
1666 | 1650 | | |
1667 | 1651 | | |
1668 | 1652 | | |
| |||
1793 | 1777 | | |
1794 | 1778 | | |
1795 | 1779 | | |
1796 | | - | |
| 1780 | + | |
1797 | 1781 | | |
1798 | 1782 | | |
1799 | 1783 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
432 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
433 | 434 | | |
434 | 435 | | |
435 | | - | |
| 436 | + | |
436 | 437 | | |
437 | 438 | | |
438 | 439 | | |
| |||
589 | 590 | | |
590 | 591 | | |
591 | 592 | | |
592 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
593 | 596 | | |
594 | 597 | | |
595 | 598 | | |
| |||
802 | 805 | | |
803 | 806 | | |
804 | 807 | | |
805 | | - | |
806 | | - | |
807 | | - | |
| 808 | + | |
808 | 809 | | |
809 | 810 | | |
810 | 811 | | |
| |||
0 commit comments