HiGHS API interface improvements including time_limit #641
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the HiGHS API interface:
Add the setting of a time_limit and significantly speed up solution processing
Picking up from the stale branch and PR (Implementing TimeLimit for highspy #614), where the implementation is correct but the tests failed. The reason why took some digging...
The time limit test for all the solvers is actually on the end-to-end time including extraction of solution values.
In this case the solver terminated correctly after 10 seconds, but ~163s were spent in extracting the solution on my machine (or 320s in CI). Specifically, calling the getitem method (i.e. []) in
solution.col_value[var.index]
is a very slow operation (presumably some type conversions via pybind11).For the 134k variables of the bin packing problem, this took 163s and failed the test, but could be reduced very easily to 0.004s 🎉 just by copying solution.col_value to a Python list first, for which index lookups are of course fast.
Demo script in a gist if curious: https://gist.github.com/aphi/4b2f7cfc7ccc52465bead3c24ee9c3f4
Enable setting of any other paramters and clean up init signature
Clean up:
epgap
was unused and deprecated in favour ofgapRel
.gapRel
as its own argument was also unsued and misleading. It was passed as an *args to the base class, which ignored the *args.gapRel
when supplied via the **kwargs to optionsDict functions the same. But now the user can also specify any parameter for HiGHS, just the same handling as the Gurobi API.I've tested this and verified it works with other parameters like
threads
andparallel
from the HiGHS optionsSome minor tidyups
Happy to make any changes - just let me know.
P.S. I contributed to this project back before it was on GitHub (2007~2011) under the guidance of stumitchell. So great to see its immense popularity today!