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

added download of highs binary. And fixed errors in subprocess #759

Merged
merged 10 commits into from
Jul 12, 2024
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
8 changes: 8 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# Copyright S.A.Mitchell ([email protected]), 2007-
# Copyright F.Peschiera ([email protected]), 2019-
# See the LICENSE file for copyright information.
2.9.0 2024-07-12
HiGHS available as solver
added HiGHS_CMD to github actions
deactivated warnings on msg=False
minor fixes
2.8.0 2024-01-12
mip start in HiGHS_CMD and SCIP_PY
GUROBI solver with environment handling
Expand Down
2 changes: 1 addition & 1 deletion pulp/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def listSolvers(onlyAvailable=False):
"""
result = []
for s in _all_solvers:
solver = s()
solver = s(msg=False)
if (not onlyAvailable) or solver.available():
result.append(solver.name)
del solver
Expand Down
4 changes: 3 additions & 1 deletion pulp/apis/coin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ def solve_CBC(self, lp, use_mps=True):
"Pulp: Error while trying to execute, use msg=True for more details"
+ self.path
)
if pipe:
try:
pipe.close()
except:
pass
if not os.path.exists(tmpSol):
raise PulpSolverError("Pulp: Error while executing " + self.path)
(
Expand Down
14 changes: 9 additions & 5 deletions pulp/apis/copt_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
import warnings

from uuid import uuid4
from .core import sparse, ctypesArrayFill, PulpSolverError
from .core import clock, log

from .core import LpSolver, LpSolver_CMD
from .core import (
sparse,
ctypesArrayFill,
PulpSolverError,
LpSolver,
LpSolver_CMD,
clock,
operating_system,
)
from ..constants import (
LpStatusNotSolved,
LpStatusOptimal,
Expand Down Expand Up @@ -894,7 +899,6 @@ def __init__(
logPath=logPath,
warmStart=warmStart,
)

self.coptenv = coptpy.Envr()
self.coptmdl = self.coptenv.createModel()

Expand Down
3 changes: 2 additions & 1 deletion pulp/apis/gurobi_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ def available(self):
# normal execution
return True
# error: we display the gurobi message
warnings.warn(f"GUROBI error: {out}.")
if self.msg:
warnings.warn(f"GUROBI error: {out}.")
return False

def actualSolve(self, lp):
Expand Down
13 changes: 9 additions & 4 deletions pulp/apis/highs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from typing import List

from .core import LpSolver, LpSolver_CMD, subprocess, PulpSolverError
import os, sys
import os
from .. import constants


Expand Down Expand Up @@ -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()
Expand Down
7 changes: 1 addition & 6 deletions pulp/pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,7 @@
from . import constants as const
from . import mps_lp as mpslp

try:
from collections.abc import Iterable
except ImportError:
# python 2.7 compatible
from collections.abc import Iterable

from collections.abc import Iterable
import logging

log = logging.getLogger(__name__)
Expand Down
4 changes: 4 additions & 0 deletions pulp/tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@


def pulpTestAll(test_docs=False):
all_solvers = pulp.listSolvers(onlyAvailable=False)
available = pulp.listSolvers(onlyAvailable=True)
print(f"Available solvers: {available}")
print(f"Unavailable solvers: {set(all_solvers) - set(available)}")
runner = unittest.TextTestRunner()
suite_all = get_test_suite(test_docs)
# we run all tests at the same time
Expand Down
Loading