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

MAINT,ENH: Minimal linprog SciPy changes #1460

Merged
merged 19 commits into from
Oct 15, 2023
Merged
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
13 changes: 11 additions & 2 deletions .github/workflows/build-meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,21 @@ jobs:
ninja
zlib
catch2
numpy
cache-environment: true
init-shell: >-
bash
zsh
- name: Build and test
shell: bash -l {0}
run: |
meson setup bbdir_test -Duse_zlib=enabled -Dwith_tests=True --prefix $CONDA_PREFIX
meson test -C bbdir_test
meson setup bbdir -Duse_zlib=enabled -Dwith_tests=True
meson test -C bbdir
- name: Test compiled highspy
shell: bash -l {0}
run: |
meson configure bbdir -Dwith_pybind11=True
meson compile -C bbdir
LD_LIBRARY_PATH=$(pwd)/bbdir/src \
PYTHONPATH=$(pwd)/bbdir \
python examples/call_highs_from_python.py
2 changes: 1 addition & 1 deletion check/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -------------------------- Configuration
test_data_conf = configuration_data()
test_data_conf.set_quoted('HIGHS_DIR',
meson.source_root())
meson.project_source_root())
configure_file(
input: 'HCheckConfig.h.meson.in',
output: 'HCheckConfig.h',
Expand Down
28 changes: 14 additions & 14 deletions examples/call_highs_from_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# The paths to MPS file instances assumes that this is run in the
# directory of this file (ie highs/examples) or any other subdirectory
# of HiGHS
import highspy
import highspy._highs
import numpy as np
inf = highspy.kHighsInf
inf = highspy._highs.kHighsInf

h = highspy.Highs()
h = highspy._highs.Highs()
alt_inf = h.getInfinity()
print('highspy.kHighsInf = ', inf, '; h.getInfinity() = ', alt_inf)
print('highspy._highs.kHighsInf = ', inf, '; h.getInfinity() = ', alt_inf)

h.addVar(-inf, inf)
h.addVar(-inf, inf)
Expand Down Expand Up @@ -41,7 +41,7 @@
print(icol, solution.col_value[icol], h.basisStatusToString(basis.col_status[icol]))

# Read in and solve avgas
h.readModel("../check/instances/avgas.mps")
h.readModel("check/instances/avgas.mps")
#h.writeModel("ml.mps")
h.run()
lp = h.getLp()
Expand All @@ -53,10 +53,10 @@

# Now define the blending model as a HighsLp instance
#
lp = highspy.HighsLp()
lp = highspy._highs.HighsLp()
lp.num_col_ = 2
lp.num_row_ = 2
lp.sense_ = highspy.ObjSense.kMaximize
lp.sense_ = highspy._highs.ObjSense.kMaximize
lp.col_cost_ = np.array([8, 10], dtype=np.double)
lp.col_lower_ = np.array([0, 0], dtype=np.double)
lp.col_upper_ = np.array([inf, inf], dtype=np.double)
Expand Down Expand Up @@ -90,7 +90,7 @@
h.clear()
# Now define the test-semi-definite0 model (from TestQpSolver.cpp) as a HighsModel instance
#
model = highspy.HighsModel()
model = highspy._highs.HighsModel()
model.lp_.model_name_ = "semi-definite"
model.lp_.num_col_ = 3
model.lp_.num_row_ = 1
Expand All @@ -99,7 +99,7 @@
model.lp_.col_upper_ = np.array([inf, inf, inf], dtype=np.double)
model.lp_.row_lower_ = np.array([2], dtype=np.double)
model.lp_.row_upper_ = np.array([inf], dtype=np.double)
model.lp_.a_matrix_.format_ = highspy.MatrixFormat.kColwise
model.lp_.a_matrix_.format_ = highspy._highs.MatrixFormat.kColwise
model.lp_.a_matrix_.start_ = np.array([0, 1, 2, 3])
model.lp_.a_matrix_.index_ = np.array([0, 0, 0])
model.lp_.a_matrix_.value_ = np.array([1.0, 1.0, 1.0], dtype=np.double)
Expand All @@ -116,19 +116,19 @@
h.clear()
num_col = 3
num_row = 1
sense = highspy.ObjSense.kMinimize
sense = highspy._highs.ObjSense.kMinimize
offset = 0
col_cost = np.array([1.0, 1.0, 2.0], dtype=np.double)
col_lower = np.array([0, 0, 0], dtype=np.double)
col_upper = np.array([inf, inf, inf], dtype=np.double)
row_lower = np.array([2], dtype=np.double)
row_upper = np.array([inf], dtype=np.double)
a_matrix_format = highspy.MatrixFormat.kColwise
a_matrix_format = highspy._highs.MatrixFormat.kColwise
a_matrix_start = np.array([0, 1, 2, 3])
a_matrix_index = np.array([0, 0, 0])
a_matrix_value = np.array([1.0, 1.0, 1.0], dtype=np.double)
a_matrix_num_nz = a_matrix_start[num_col]
hessian_format = highspy.HessianFormat.kTriangular
hessian_format = highspy._highs.HessianFormat.kTriangular
hessian_start = np.array([0, 2, 2, 3])
hessian_index = np.array([0, 2, 2])
hessian_value = np.array([2.0, -1.0, 1.0], dtype=np.double)
Expand All @@ -149,12 +149,12 @@
h.clear()
print('25fv47 as HighsModel')

h.readModel("../check/instances/25fv47.mps")
h.readModel("check/instances/25fv47.mps")
h.presolve()
presolved_lp = h.getPresolvedLp()
# Create a HiGHS instance to solve the presolved LP
print('\nCreate Highs instance to solve presolved LP')
h1 = highspy.Highs()
h1 = highspy._highs.Highs()
h1.passModel(presolved_lp)
options = h1.getOptions()
options.presolve = 'off'
Expand Down
Loading