Changeset 2166


Ignore:
Timestamp:
Jan 24, 2010 3:51:15 PM (10 years ago)
Author:
jwatson
Message:

Allowing PyomoModel? to load a solver results object with a status equal to "Warning" - the old version threw an exception if the solver status wasn't OK.

The new version does print a warning message indicating that you are loading a solver with a warning, and that the user should take a look.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/base/PyomoModel.py

    r2161 r2166  
    283283           return True
    284284        elif type(arg) is coopr.opt.SolverResults:
    285            if arg.solver.status != coopr.opt.SolverStatus.ok:
     285           # if the solver status not one of either OK or Warning, then error.
     286           if (arg.solver.status != coopr.opt.SolverStatus.ok) and (arg.solver.status != coopr.opt.SolverStatus.warning):
    286287              raise ValueError, "Cannot load a SolverResults object with bad status: "+str(arg.solver.status)
     288           # but if there is a warning, print out a warning, as someone should probably take a look!
     289           if (arg.solver.status == coopr.opt.SolverStatus.warning):
     290              print "WARNING - Loading a SolverResults object with a warning status"
    287291           if len(arg.solution) > 0:
    288292              self._load_solution(arg.solution(0),symbol_map=arg.symbol_map)
Note: See TracChangeset for help on using the changeset viewer.