diff --git a/pulp/apis/highs_api.py b/pulp/apis/highs_api.py index b233a626..f40275c5 100644 --- a/pulp/apis/highs_api.py +++ b/pulp/apis/highs_api.py @@ -28,7 +28,7 @@ # Users would need to install HiGHS on their machine and provide the path to the executable. Please look at this thread: https://github.com/ERGO-Code/HiGHS/issues/527#issuecomment-894852288 # More instructions on: https://www.highs.dev -from typing import List +from typing import List, Optional, Any from .core import LpSolver, LpSolver_CMD, subprocess, PulpSolverError import os, sys @@ -245,7 +245,6 @@ def actualSolve(self, lp, callback=None): raise PulpSolverError("HiGHS: Not Available") else: - # Note(maciej): It was surprising to me that higshpy wasn't logging out of the box, # even with the different logging options set. This callback seems to work, but there # are probably better ways of doing this ¯\_(ツ)_/¯ @@ -256,11 +255,35 @@ def actualSolve(self, lp, callback=None): def __init__( self, + mip=True, + msg=True, callbackTuple=None, - *args, - **solverParams, + gapAbs: Optional[float] = None, + gapRel: Optional[float] = None, + threads: Optional[int] = None, + timeLimit: Optional[float] = None, + options: Optional[list[tuple[[str, Any]]]] = None, + **kwargs, ): - super().__init__(*args, **solverParams) + """ + :param bool mip: if False, assume LP even if integer variables + :param bool msg: if False, no log is shown + :param float gapRel: relative gap tolerance for the solver to stop (in fraction) + :param float gapAbs: absolute gap tolerance for the solver to stop + :param int threads: sets the maximum number of threads + :param float timeLimit: maximum time for solver (in seconds) + :param list options: list of additional options to pass to the HiGHS solver + """ + super().__init__( + mip=mip, + msg=msg, + gapAbs=gapAbs, + gapRel=gapRel, + threads=threads, + timeLimit=timeLimit, + options=options, + **kwargs, + ) self.callbackTuple = callbackTuple def available(self):