Closed apschmidt closed 8 months ago
thanks! Would you mind doing a PR with these changes? And if you're feeling more generous, you can add highspy to the solvers that are tested with timeLimit here: https://github.com/coin-or/pulp/blob/006753076be18ee857339d333a5db11e599f21a2/pulp/tests/test_pulp.py#L1210-L1217
I can try! I am new to GitHub, so I may take a bit to figure it out. Currently, I am unable to make a new branch however.
Great! Check https://coin-or.github.io/pulp/develop/contribute.html for some basic information. Have fun : )
I'm closing since the functionality now offers this possibility in the HiGHS solver. Please re-open if needed.
Details for the issue
What did you do?
Attempted to use HiGHS solver (as detailed below) to solve a MIP.
solver = getSolver('HiGHS', timeLimit=10, msg = True)
prob.solve(solver)
What did you expect to see?
I expected to see the output below. Note the status is "Time Limit Reached" in the Status Report.
What did you see instead?
The pulp api (highs_api.py) does not pass the timeLimit parameter to the HiGHS solver. As a result, the timeLimit is ignored and the branch-and-bound is run until the optimal solution is found. See below for output.
Useful extra information
I have found a quick-fix, but I am unsure of a sustainable solution.
Specifically, I have modified the HiGHS class in the highs_api.py file. The changes were as follows:
super().__init__(mip, msg, timeLimit, gapRel=gapRel, *args, **solverParams)
tosuper().__init__(mip, msg, timeLimit = timeLimit, gapRel=gapRel, *args, **solverParams)
. Note this is because the third argument in the super.init() is "options" not "timeLimit".if self.timeLimit is not None: lp.solverModel.setOptionValue("time_limit", float(self.timeLimit))
directly followinglp.solverModel.setOptionValue("mip_rel_gap", gapRel):
The info below often helps, please fill it out if you're able to. :)
What operating system are you using?
I'm using python version:
I installed PuLP via:
Did you also