Skip to content

Commit

Permalink
BUG: Fix gh-15888
Browse files Browse the repository at this point in the history
More of a dodge than a fix, but will essentially work with exceptions now.
  • Loading branch information
HaoZeke committed Jul 30, 2023
1 parent 604e7a2 commit 14f6de3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scipy/optimize/_highs/cython/src/Highs.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cdef extern from "Highs.h":
cdef cppclass Highs:
HighsStatus passHighsOptions(const HighsOptions& options)
HighsStatus passModel(const HighsLp& lp)
HighsStatus run()
HighsStatus run() except +
HighsStatus setHighsLogfile(FILE* logfile)
HighsStatus setHighsOutput(FILE* output)
HighsStatus writeHighsOptions(const string filename, const bool report_only_non_default_values = true)
Expand Down
14 changes: 13 additions & 1 deletion scipy/optimize/_highs/cython/src/_highs_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,19 @@ def _highs_wrapper(
}

# Solve the LP
cdef HighsStatus run_status = highs.run()
# Declare the variable outside the try block
cdef HighsStatus run_status = HighsStatusOK
try:
# Attempt to run the operation that might throw an exception
run_status = highs.run()
except Exception as e:
# Handle the exception as needed, such as by printing an error message and returning
print(f"The problem is too large to be solved. Details: {e}")
return {
'status': -1, # or some other status code indicating an error
'message': "The problem is too large to be solved.",
}

if run_status == HighsStatusError:
return {
'status': <int> highs.getModelStatus(),
Expand Down

0 comments on commit 14f6de3

Please sign in to comment.