@@ -42,27 +42,53 @@ class COIN_CMD(LpSolver_CMD):
4242 def defaultPath (self ):
4343 return self .executableExtension (cbc_path )
4444
45- def __init__ (self , fracGap = None , maxSeconds = None , * args , ** kwargs ):
45+ def __init__ (self , mip = True , msg = True , timeLimit = None ,
46+ fracGap = None , maxSeconds = None , gapRel = None , gapAbs = None ,
47+ presolve = None , cuts = None , strong = None , options = None ,
48+ warmStart = False , keepFiles = False , path = None , threads = None ,
49+ logPath = None , mip_start = False ):
4650 """
47- :param fracGap:
48- :param maxSeconds:
49- :param args:
50- :param kwargs: includes presolve, cuts, strong
51+ :param bool mip: if False, assume LP even if integer variables
52+ :param bool msg: if False, no log is shown
53+ :param float timeLimit: maximum time for solver (in seconds)
54+ :param float gapRel: relative gap tolerance for the solver to stop (in fraction)
55+ :param float gapAbs: absolute gap tolerance for the solver to stop
56+ :param int threads: sets the maximum number of threads
57+ :param list options: list of additional options to pass to solver
58+ :param bool warmStart: if True, the solver will use the current value of variables as a start
59+ :param bool keepFiles: if True, files are saved in the current directory and not deleted after solving
60+ :param str path: path to the solver binary
61+ :param str logPath: path to the log file
62+ :param bool presolve: if True, adds presolve on
63+ :param bool cuts: if True, adds gomory on knapsack on probing on
64+ :param bool strong: if True, adds strong
65+ :param float fracGap: deprecated for gapRel
66+ :param float maxSeconds: deprecated for timeLimit
67+ :param bool mip_start: deprecated for warmStart
5168 """
5269
53- if fracGap :
54- warnings .warn ("Parameter fracGap is being depreciated for standard ' gapRel' " )
55- if ' gapRel' in kwargs :
56- warnings .warn ("Parameter kwargs and fracGap passed, using kwargs " )
70+ if fracGap is not None :
71+ warnings .warn ("Parameter fracGap is being depreciated for gapRel" )
72+ if gapRel is not None :
73+ warnings .warn ("Parameter gapRel and fracGap passed, using gapRel " )
5774 else :
58- kwargs ['gapRel' ] = fracGap
59- LpSolver_CMD .__init__ (self , * args , ** kwargs )
60- if maxSeconds :
61- warnings .warn ("Parameter maxSeconds is being depreciated for standard 'timeLimit'" )
62- if self .timeLimit :
63- warnings .warn ("Parameter timeLimit and maxSeconds passed, using timeLimit " )
75+ gapRel = fracGap
76+ if maxSeconds is not None :
77+ warnings .warn ("Parameter maxSeconds is being depreciated for timeLimit" )
78+ if timeLimit is not None :
79+ warnings .warn ("Parameter timeLimit and maxSeconds passed, using timeLimit" )
6480 else :
65- self .timeLimit = maxSeconds
81+ timeLimit = maxSeconds
82+ if mip_start :
83+ warnings .warn ("Parameter mip_start is being depreciated for warmStart" )
84+ if warmStart :
85+ warnings .warn ("Parameter mipStart and mip_start passed, using warmStart" )
86+ else :
87+ warmStart = mip_start
88+ LpSolver_CMD .__init__ (self , gapRel = gapRel , mip = mip , msg = msg , timeLimit = timeLimit ,
89+ presolve = presolve , cuts = cuts , strong = strong , options = options ,
90+ warmStart = warmStart , path = path , keepFiles = keepFiles ,
91+ threads = threads , gapAbs = gapAbs , logPath = logPath )
6692
6793 def copy (self ):
6894 """Make a copy of self"""
@@ -96,7 +122,7 @@ def solve_CBC(self, lp, use_mps=True):
96122 constraintsNames = dict ((c , c ) for c in lp .constraints )
97123 objectiveName = None
98124 cmds = ' ' + tmpLp + " "
99- if self .warmStart :
125+ if self .optionsDict . get ( ' warmStart' , False ) :
100126 self .writesol (tmpMst , lp , vs , variablesNames , constraintsNames )
101127 cmds += 'mips {} ' .format (tmpMst )
102128 if self .timeLimit is not None :
@@ -114,7 +140,8 @@ def solve_CBC(self, lp, use_mps=True):
114140 pipe = None
115141 else :
116142 pipe = open (os .devnull , 'w' )
117- if 'logPath' in self .optionsDict :
143+ logPath = self .optionsDict .get ('logPath' )
144+ if logPath :
118145 if self .msg :
119146 warnings .warn ('`logPath` argument replaces `msg=1`. The output will be redirected to the log file.' )
120147 pipe = open (self .optionsDict ['logPath' ], 'w' )
@@ -258,14 +285,19 @@ def actualSolve(self, lp, callback = None):
258285 """Solve a well formulated lp problem"""
259286 raise PulpSolverError ("PULP_CBC_CMD: Not Available (check permissions on %s)" % self .pulp_cbc_path )
260287 else :
261- def __init__ (self , path = None , * args , ** kwargs ):
262- """
263- just loads up COIN_CMD with the path set
264- """
288+ def __init__ (self , mip = True , msg = True , timeLimit = None ,
289+ fracGap = None , maxSeconds = None , gapRel = None , gapAbs = None ,
290+ presolve = None , cuts = None , strong = None , options = None ,
291+ warmStart = False , keepFiles = False , path = None , threads = None ,
292+ logPath = None , mip_start = False ):
265293 if path is not None :
266294 raise PulpSolverError ('Use COIN_CMD if you want to set a path' )
267295 #check that the file is executable
268- COIN_CMD .__init__ (self , path = self .pulp_cbc_path , * args , ** kwargs )
296+ COIN_CMD .__init__ (self , path = self .pulp_cbc_path , mip = mip , msg = msg , timeLimit = timeLimit ,
297+ fracGap = fracGap , maxSeconds = maxSeconds , gapRel = gapRel , gapAbs = gapAbs ,
298+ presolve = presolve , cuts = cuts , strong = strong , options = options ,
299+ warmStart = warmStart , keepFiles = keepFiles , threads = threads ,
300+ logPath = logPath , mip_start = mip_start )
269301
270302
271303def COINMP_DLL_load_dll (path ):
0 commit comments