Changeset 2631
- Timestamp:
- May 24, 2010 11:25:03 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
coopr.plugins/trunk/coopr/plugins/mip/CBCplugin.py
r2593 r2631 312 312 results.problem.number_of_objectives=1 313 313 314 processing_constraints=None # None means header, True means constraints, False means variables. 314 processing_constraints = None # None means header, True means constraints, False means variables. 315 header_processed = False 315 316 INPUT = open(self.soln_file,"r") 316 317 for line in INPUT: 317 318 tokens = re.split('[ \t]+',line.strip()) 318 #print "LINE",line,len(tokens) 319 if tokens[0] in ("Optimal", "Status"): 320 # TBD - this logic isn't correct/complete. flush out as necessary. 321 continue 322 if tokens[0] == "0": # indicates section start. 319 # these are the only header entries CBC will generate (identified via browsing CbcSolver.cpp) 320 if tokens[0] in ("Optimal", "Infeasible", "Unbounded", "Stopped", "Integer", "Status"): 321 if tokens[0] == "Optimal": 322 solution.status = SolutionStatus.optimal 323 solution.gap = 0.0 324 solution.objective['f'].value = eval(tokens[-1]) 325 elif tokens[0] == "Infeasible": 326 solution.status = SolutionStatus.infeasible 327 solution.gap = None 328 return 329 else: 330 print "***WARNING: CBC plugin currently not processing solution status="+tokens[0]+" correctly. Full status line is: "+string.strip(line) 331 header_processed = True 332 333 elif tokens[0] == "0": # indicates section start. 323 334 if processing_constraints is None: 324 335 processing_constraints = True … … 326 337 processing_constraints = False 327 338 else: 328 raise RuntimeError, "CBC encountered unexpected line=("+line.strip()+") in solution file="+self.soln_file+"; constraint and variable sections already processed!"339 raise RuntimeError, "CBC plugin encountered unexpected line=("+line.strip()+") in solution file="+self.soln_file+"; constraint and variable sections already processed!" 329 340 330 341 if (processing_constraints is True) and (extract_duals is True): … … 332 343 constraint_ax = eval(tokens[2]) # CBC reports the constraint row times the solution vector - not the slack. 333 344 constraint_dual = eval(tokens[3]) 334 335 345 solution.constraint[constraint].dual = constraint_dual 336 346 … … 339 349 variable_value = eval(tokens[2]) 340 350 solution.variable[variable_name].value = variable_value 341 342 351 if extract_reduced_costs is True: 343 352 variable_reduced_cost = eval(tokens[3]) # currently ignored. 344 353 solution.variable[variable_name].rc = variable_reduced_cost 354 355 elif header_processed is True: 356 pass 357 345 358 else: 346 raise RuntimeError, "CBC encountered unexpected line=("+line.strip()+") in solution file="+self.soln_file+"; expecting header, but found data!"359 raise RuntimeError, "CBC plugin encountered unexpected line=("+line.strip()+") in solution file="+self.soln_file+"; expecting header, but found data!" 347 360 348 361 INPUT.close() … … 384 397 385 398 pyutilib.services.register_executable(name="cbc") 386
Note: See TracChangeset
for help on using the changeset viewer.