Changeset 2168
 Timestamp:
 Jan 24, 2010 4:07:25 PM (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

coopr.plugins/trunk/coopr/plugins/mip/CPLEX.py
r2100 r2168 26 26 import xml.dom.minidom 27 27 28 import time 29 28 30 29 31 class CPLEX(ILMLicensedSystemCallSolver): … … 153 155 raise ValueError, "CPLEX _presolve method can only handle a single problem instance  "+str(len(args))+" were supplied" 154 156 155 if self._hasIntegerVariables(args[0]) is True: 157 if self._hasIntegerVariables(args[0]) is True: 158 start_time = time.time() 156 159 self.write_warmstart_file(args[0]) 160 end_time = time.time() 161 print "Warm start write time="+str(end_timestart_time)+" seconds" 157 162 158 163 # let the base class handle any remaining keywords/actions. … … 259 264 tokens = re.split('[ \t]+',line.strip()) 260 265 if len(tokens) > 3 and tokens[0] == "CPLEX" and tokens[1] == "Error": 266 # IMPT: See below  cplex can generate an error line and then terminate fine, e.g., in CPLEX 12.1. 267 # To handle these cases, we should be specifying some kind of termination criterion always 268 # in the course of parsing a log file (we aren't doing so currently  just in some conditions). 261 269 results.solver.status=SolverStatus.error 262 270 results.solver.error = " ".join(tokens) … … 264 272 cplex_version = tokens[2].rstrip(',') 265 273 elif len(tokens) >= 3 and tokens[0] == "Variables": 266 if results.problem.number_of_variables is None: # CPLEX 11.2 and subsequent has two Variables sections.274 if results.problem.number_of_variables is None: # CPLEX 11.2 and subsequent versions have two Variables sections in the log file output. 267 275 results.problem.number_of_variables = tokens[2] 268 276 # In CPLEX 11 (and presumably before), there was only a single line output to … … 285 293 # to differentiate, and I'm not sure we can always provide a breakdown. 286 294 results.solver.user_time = eval(tokens[3]) 287 elif len(tokens) >= 4 and tokens == ['MIP', '', 'Integer', 'infeasible.']: 295 elif len(tokens) >= 4 and tokens[0] == "Dual" and tokens[1] == "simplex" and tokens[3] == "Optimal:": 296 results.solver.termination_condition = TerminationCondition.optimal 297 results.solver.termination_message = ' '.join(tokens) 298 elif len(tokens) >= 4 and tokens[0] == "MIP" and tokens[2] == "Integer" and tokens[3] == "infeasible.": 299 # if CPLEX has previously printed an error message, reduce it to a warning  300 # there is a strong indication it recovered, but we can't be sure. 301 if results.solver.status == SolverStatus.error: 302 results.solver.status = SolverStatus.warning 303 else: 304 results.solver.status = SolverStatus.ok 288 305 results.solver.termination_condition = TerminationCondition.infeasible 289 306 results.solver.termination_message = ' '.join(tokens) 290 elif len(tokens) >= 3 and tokens == ['Presolve', '', 'Infeasible.']: 307 # for the case below, CPLEX sometimes reports "true" optimal (the first case) 308 # and other times withintolerance optimal (the second case). 309 elif (len(tokens) >= 4 and tokens[0] == "MIP" and tokens[2] == "Integer" and tokens[3] == "optimal") or \ 310 (len(tokens) >= 4 and tokens[0] == "MIP" and tokens[2] == "Integer" and tokens[3] == "optimal,"): 311 # if CPLEX has previously printed an error message, reduce it to a warning  312 # there is a strong indication it recovered, but we can't be sure. 313 if results.solver.status == SolverStatus.error: 314 results.solver.status = SolverStatus.warning 315 else: 316 results.solver.status = SolverStatus.ok 317 results.solver.termination_condition = TerminationCondition.optimal 318 results.solver.termination_message = ' '.join(tokens) 319 elif len(tokens) >= 3 and tokens[0] == "Presolve" and tokens[2] == "Infeasible.": 320 # if CPLEX has previously printed an error message, reduce it to a warning  321 # there is a strong indication it recovered, but we can't be sure. 322 if results.solver.status == SolverStatus.error: 323 results.solver.status = SolverStatus.warning 324 else: 325 results.solver.status = SolverStatus.ok 291 326 results.solver.termination_condition = TerminationCondition.infeasible 292 327 results.solver.termination_message = ' '.join(tokens) 293 elif len(tokens) >= 5 and tokens == ['Presolve', '', 'Unbounded', 'or', 'infeasible.']: 328 elif len(tokens) >= 5 and tokens[0] == "Presolve" and tokens[2] == "Unbounded" and tokens[4] == "infeasible.": 329 # if CPLEX has previously printed an error message, reduce it to a warning  330 # there is a strong indication it recovered, but we can't be sure. 331 if results.solver.status == SolverStatus.error: 332 results.solver.status = SolverStatus.warning 333 else: 334 results.solver.status = SolverStatus.ok 294 335 # It isn't clear whether we can determine if the problem is unbounded from 295 336 # CPLEX's output. … … 401 442 elif tokens[0].startswith("solutionStatusString"): 402 443 solution_status = (string.strip(" ".join(tokens).split('=')[1])).lstrip("\"").rstrip("\"") 403 if solution_status in ["optimal", "integer optimal solution" ]:444 if solution_status in ["optimal", "integer optimal solution", "integer optimal, tolerance"]: 404 445 soln.status = SolutionStatus.optimal 405 446 soln.gap = 0.0
Note: See TracChangeset
for help on using the changeset viewer.