Changeset 9496


Ignore:
Timestamp:
Dec 17, 2014 10:25:53 AM (4 years ago)
Author:
gahacke
Message:

only extract solution gap when problem is discrete; avoid confusing warning message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyomo/trunk/pyomo/solvers/plugins/solvers/CPLEXDirect.py

    r9392 r9496  
    920920        # extraction of the absolute gap, so we have to compute it.
    921921        m = instance.solution.quality_metric
    922         try:
     922        if instance.get_problem_type() in [instance.problem_type.MILP,
     923                                           instance.problem_type.MIQP,
     924                                           instance.problem_type.MIQCP]:
    923925            relative_gap = instance.solution.MIP.get_mip_relative_gap()
    924926            best_integer = instance.solution.MIP.get_best_objective()
    925927            diff = relative_gap * (1.0e-10 + math.fabs(best_integer))
    926             soln.gap = diff
    927         except CplexError:
    928             #
    929             # If an error occurs, then the model is not a MIP
    930             #
    931             pass
     928            soln.gap = diff
    932929
    933930        #Only try to get objective and variable values if a solution exists
Note: See TracChangeset for help on using the changeset viewer.