Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions build/pkgs/highspy/SPKG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
highs: Linear optimization solver with Python bindings
======================================================

Description
-----------

HiGHS is a high performance serial and parallel solver for large scale sparse
linear optimization problems of the form:

min c'x subject to L <= Ax <= U; l <= x <= u

where c, x, L, U, l, u are vectors and A is a matrix.

HiGHS has implementations of the dual revised simplex method, primal and dual
revised simplex solvers, an interior point solver, and a MIP solver.

This package includes the highspy Python bindings built using pybind11.

License
-------

- MIT License

Upstream Contact
----------------

- https://github.com/ERGO-Code/HiGHS
- https://www.highs.dev
- Email: [email protected]

Dependencies
------------

- CMake (build dependency)
- scikit-build-core (build dependency)
- pybind11 (build dependency)
- numpy

Special Update/Build Instructions
----------------------------------

The Python bindings (highspy) are built automatically via pip using the
pyproject.toml included in the HiGHS source distribution.
4 changes: 4 additions & 0 deletions build/pkgs/highspy/checksums.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tarball=highs-VERSION.tar.gz
sha1=576cf6f0fe03a57ebcf6acc6fe77b230b454b0bd
sha256=2b44b074cf41439325ce4d0bbdac2d51379f56faf17ba15320a410d3c1f07275
upstream_url=https://github.com/ERGO-Code/HiGHS/archive/refs/tags/vVERSION.tar.gz
4 changes: 4 additions & 0 deletions build/pkgs/highspy/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$(PYTHON) numpy scikit_build_core pybind11 cmake | $(PYTHON_TOOLCHAIN)

----------
All lines of this file are ignored except the first.
Empty file added build/pkgs/highspy/math
Empty file.
1 change: 1 addition & 0 deletions build/pkgs/highspy/package-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.11.0
2 changes: 2 additions & 0 deletions build/pkgs/highspy/spkg-install.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd src
sdh_pip_install .
1 change: 1 addition & 0 deletions build/pkgs/highspy/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optional
35 changes: 35 additions & 0 deletions build/pkgs/scikit_build_core/SPKG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
scikit_build_core: Build backend for CMake Python projects
===========================================================

Description
-----------

Scikit-build-core is a build backend for CMake-based Python projects.
It is a complete ground-up rewrite of scikit-build that provides modern
standards-based build backend support for CMake.

This package is required as a build dependency for packages that use
scikit-build-core, such as HiGHS.

License
-------

- Apache-2.0

Upstream Contact
----------------

- https://github.com/scikit-build/scikit-build-core
- https://scikit-build-core.readthedocs.io/

Dependencies
------------

- packaging
- pathspec
- pyproject_metadata

Special Update/Build Instructions
----------------------------------

None.
4 changes: 4 additions & 0 deletions build/pkgs/scikit_build_core/checksums.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tarball=scikit_build_core-VERSION.tar.gz
sha1=52e4271301132ecd35d16534f63d6ec723ae5780
sha256=5982ccd839735be99cfd3b92a8847c6c196692f476c215da84b79d2ad12f9f1b
upstream_url=https://pypi.io/packages/source/s/scikit-build-core/scikit_build_core-VERSION.tar.gz
4 changes: 4 additions & 0 deletions build/pkgs/scikit_build_core/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$(PYTHON) packaging pathspec pyproject_metadata|hatchling hatch_vcs $(PYTHON_TOOLCHAIN)

----------
All lines of this file are ignored except the first.
1 change: 1 addition & 0 deletions build/pkgs/scikit_build_core/package-version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.11.6
2 changes: 2 additions & 0 deletions build/pkgs/scikit_build_core/spkg-install.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd src
sdh_pip_install .
1 change: 1 addition & 0 deletions build/pkgs/scikit_build_core/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optional
15 changes: 13 additions & 2 deletions src/sage/numerical/backends/generic_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1712,8 +1712,15 @@ def default_mip_solver(solver=None):
except ImportError:
raise ValueError("SCIP is not available. Please refer to the documentation to install it.")

elif solver == "Highs":
try:
from sage.numerical.backends.highs_backend import HiGHSBackend
default_solver = solver
except ImportError:
raise ValueError("HiGHS is not available. Please refer to the documentation to install it.")

else:
raise ValueError("'solver' should be set to 'GLPK', 'Coin', 'CPLEX', 'CVXOPT', 'CVXPY', 'Gurobi', 'PPL', 'SCIP', 'InteractiveLP', a callable, or None.")
raise ValueError("'solver' should be set to 'GLPK', 'Coin', 'CPLEX', 'CVXOPT', 'CVXPY', 'Gurobi', 'PPL', 'SCIP', 'HiGHS', 'InteractiveLP', a callable, or None.")


cpdef GenericBackend get_solver(constraint_generation=False, solver=None, base_ring=None):
Expand Down Expand Up @@ -1883,5 +1890,9 @@ cpdef GenericBackend get_solver(constraint_generation=False, solver=None, base_r
from sage.numerical.backends.scip_backend import SCIPBackend
return SCIPBackend()

elif solver == "Highs":
from sage.numerical.backends.highs_backend import HiGHSBackend
return HiGHSBackend()

else:
raise ValueError("'solver' should be set to 'GLPK', 'GLPK/exact', 'Coin', 'CPLEX', 'CVXOPT', 'CVXPY', 'Gurobi', 'PPL', 'SCIP', 'InteractiveLP', None (in which case the default one is used), or a callable.")
raise ValueError("'solver' should be set to 'GLPK', 'GLPK/exact', 'Coin', 'CPLEX', 'CVXOPT', 'CVXPY', 'Gurobi', 'PPL', 'SCIP', 'HiGHS', 'InteractiveLP', None (in which case the default one is used), or a callable.")
29 changes: 29 additions & 0 deletions src/sage/numerical/backends/highs_backend.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#*****************************************************************************
# Copyright (C) 2025 SageMath Developers
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************

from sage.numerical.backends.generic_backend cimport GenericBackend

cdef class HiGHSBackend(GenericBackend):
cdef object highs_model
cdef str prob_name
cdef dict col_name_var
cdef dict row_name_var
cdef dict row_data_cache
cdef int numcols
cdef int numrows
cpdef __copy__(self)
cpdef get_row_prim(self, int i)
cpdef double get_row_dual(self, int i) except? -1
cpdef double get_col_dual(self, int j) except? -1
cpdef int get_row_stat(self, int i) except? -1
cpdef int get_col_stat(self, int j) except? -1
cpdef set_row_stat(self, int i, int stat)
cpdef set_col_stat(self, int j, int stat)
cpdef int warm_up(self) noexcept
Loading
Loading