diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 7e7886f9..6cbe10f7 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -49,6 +49,14 @@ jobs: # alternatively if: contains(fromJSON("['3.7', '3.8', '3.9', '3.10', '3.11']"), matrix.python-version) run: | pip install highspy numpy + - name: Install highspy cmd + if: matrix.os == 'ubuntu-latest' + uses: supplypike/setup-bin@v4 + with: + uri: 'https://github.com/JuliaBinaryWrappers/HiGHSstatic_jll.jl/releases/download/HiGHSstatic-v1.7.1%2B0/HiGHSstatic.v1.7.1.x86_64-linux-gnu-cxx11.tar.gz' + subPath: 'bin' + name: 'highs' + version: '1.7.1' - name: Install coptpy run: | pip install coptpy diff --git a/pulp/apis/highs_api.py b/pulp/apis/highs_api.py index 4915217e..cbc0ea09 100644 --- a/pulp/apis/highs_api.py +++ b/pulp/apis/highs_api.py @@ -32,7 +32,7 @@ from typing import List from .core import LpSolver, LpSolver_CMD, subprocess, PulpSolverError -import os, sys +import os from .. import constants @@ -149,14 +149,19 @@ def actualSolve(self, lp): with open(tmpOptions, "w") as options_file: options_file.write("\n".join(file_options)) - process = subprocess.run(command, stdout=sys.stdout, stderr=sys.stderr) + # print(command) + process = subprocess.Popen(command, stdout=None, stderr=None) # HiGHS return code semantics (see: https://github.com/ERGO-Code/HiGHS/issues/527#issuecomment-946575028) # - -1: error # - 0: success # - 1: warning - if process.returncode == -1: - raise PulpSolverError("Error while executing HiGHS") + # process = subprocess.run(command, stdout=sys.stdout, stderr=sys.stderr) + if process.wait() == -1: + raise PulpSolverError( + "Pulp: Error while executing HiGHS, use msg=True for more details" + + self.path + ) with open(highs_log_file, "r") as log_file: lines = log_file.readlines() diff --git a/pulp/tests/test_pulp.py b/pulp/tests/test_pulp.py index 7093e5a3..119d6e30 100644 --- a/pulp/tests/test_pulp.py +++ b/pulp/tests/test_pulp.py @@ -836,12 +836,11 @@ def test_msg_arg(self): data = prob.toDict() var1, prob1 = LpProblem.fromDict(data) x, y, z, w = (var1[name] for name in ["x", "y", "z", "w"]) - if self.solver.name in ["HiGHS"]: - # HiGHS has issues with displaying output in Ubuntu - return - self.solver.msg = True pulpTestCheck( - prob1, self.solver, [const.LpStatusOptimal], {x: 4, y: -1, z: 6, w: 0} + prob1, + self.solveInst(msg=True), + [const.LpStatusOptimal], + {x: 4, y: -1, z: 6, w: 0}, ) def test_pulpTestAll(self): @@ -1278,6 +1277,7 @@ def test_measuring_solving_time(self): CPLEX_CMD=50, GUROBI=50, HiGHS=50, + HiGHS_CMD=50, ) bins = solver_settings.get(self.solver.name) if bins is None: @@ -1308,7 +1308,7 @@ def test_time_limit_no_solution(self): print("\t Test time limit with no solution") time_limit = 1 - solver_settings = dict(HiGHS=50, PULP_CBC_CMD=30, COIN_CMD=30) + solver_settings = dict(HiGHS_CMD=50, HiGHS=50, PULP_CBC_CMD=30, COIN_CMD=30) bins = solver_settings.get(self.solver.name) if bins is None: # not all solvers have timeLimit support