Changeset 3154


Ignore:
Timestamp:
Oct 25, 2010 12:14:58 AM (10 years ago)
Author:
jwatson
Message:

Modifed GUROBI plug-in to only extract duals when the underlying model is linear. Otherwise (obviously) they aren't available.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.plugins/trunk/coopr/plugins/mip/GUROBI_RUN.py

    r3135 r3154  
    1313
    1414def gurobi_run(model_file, soln_file):
     15
    1516    # Load the lp model
    1617    model = read(model_file)
     
    141142    print >>solnfile, 'termination_message:', message
    142143
     144    is_discrete = False
     145    if (model.getAttr(GRB.Attr.NumBinVars) > 0) or (model.getAttr(GRB.Attr.NumIntVars) > 0):
     146       is_discrete = True
     147
    143148    #TODO: Can we query GUROBI to find out if an incumbent exists
    144149    if (term_cond == 'globallyOptimal'):
     
    149154        print >>solnfile, 'objective:',obj_value
    150155
    151 #        for con in cons:
    152 #            print >>solnfile, "constraint:",con.getAttr(GRB.Attr.ConstrName),":",con.getAttr(GRB.Attr.Pi)
    153 
    154156        for var in vars:
    155157            print >>solnfile, 'variable:',var.getAttr(GRB.Attr.VarName), ":",var.getAttr(GRB.Attr.X)
     158
     159        if is_discrete is False:
     160           for con in cons:
     161               print >>solnfile, "constraint:",con.getAttr(GRB.Attr.ConstrName),":",con.getAttr(GRB.Attr.Pi)
    156162
    157163    solnfile.close()
Note: See TracChangeset for help on using the changeset viewer.