在pulp中,您可以调用其他外部解算器,例如cplex和gurobi。通常,在调用解算器时,可以在参数中设置时间限制和最佳间隔。以古罗比为例:
prob = LpProblem("anything", LpMinimize)prob.solve(GUROBI(timeLimit=1200))
例如,如果您使用的是gurobi,请参见init paramsclass GUROBI(LpSolver):
"""
The Gurobi LP/MIP solver (via its python interface)
The Gurobi variables are available (after a solve) in var.solverVar
Constriaints in constraint.solverConstraint
and the Model is in prob.solverModel
"""
try:
sys.path.append(gurobi_path)
# to import the name into the module scope
global gurobipy
import gurobipy
except: #FIXME: Bug because gurobi returns
#a gurobi exception on failed imports
def available(self):
"""True if the solver is available"""
return False
def actualSolve(self, lp, callback = None):