Skip to content

Commit

Permalink
Add parameters back back into the solver
Browse files Browse the repository at this point in the history
  • Loading branch information
siwy committed Mar 24, 2023
1 parent b6920b9 commit b73e6d4
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions pulp/apis/highs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ¯\_(ツ)_/¯
Expand All @@ -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):
Expand Down

0 comments on commit b73e6d4

Please sign in to comment.