Ticket #4487 (new minor enhancement)

Opened 6 years ago

Last modified 4 years ago

results object status are inconsistent across plugins

Reported by: gabeh Owned by: unassigned
Priority: major Milestone: Long Term
Component: pyomo.solvers Version:
Keywords: results, status, plugins, inconsistent Cc:


In order to properly check for solution feasibility AND be able to switch between solvers and solver interface is an overly difficult task right now.

For example, the minimum amount of code required to handle all combinations of Gurobi and CPLEX and their respective LP, NL, and Python interfaces is the following mess:

from coopr.opt import SolverStatus, TerminationCondition, SolutionStatus

if (results.solver.status == SolverStatus.ok) and \
   ( (results.solver.termination_condition == TerminationCondition.optimal) or \
      ((len(results.solution) > 0) and (results.solution(0).status == SolutionStatus.optimal))  ):                                                                 
    print 'Feasible Iteration'
    # do something
elif (results.solver.termination_condition == TerminationCondition.infeasible) or \
       ((len(results.solution) > 0) and (results.solution(0).status == SolutionStatus.infeasible)):
    print 'Infeasible Iteration'
    # do something
    print "Unhandled results status:"
    print "Solver Status:", results.solver.status
    print "Solver Termination Condition:", results.solver.termination_condition
    if len(results.solution) > 0:
        print "Solution Status:", results.solution(0).status
        print "Solution Status: No Solution Reported"

It's possible this code would need to be expanded if other solver plugins are considered. It would be nice if we could clean this up. Checking for solution feasibility is a very common task in generic algorithm scripting, and the above approach is far from obvious for most (if not all) users.

Change History

comment:1 Changed 4 years ago by wehart

  • Milestone changed from Pyomo 4.0 to Pyomo 4.1

comment:2 Changed 4 years ago by wehart

  • Milestone changed from Pyomo 4.1 to Long Term
Note: See TracTickets for help on using tickets.