Changeset 3457


Ignore:
Timestamp:
Jan 13, 2011 6:12:14 PM (9 years ago)
Author:
jwatson
Message:

Fixing bug in output of constraint offset - minor performance improvement in dictionary manipulation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/io/cpxlp.py

    r3456 r3457  
    152152              # due to potential disabling of expression simplification,
    153153              # variables might appear more than once - condense coefficients.
    154               if name_to_coefficient_map.has_key(name) is False:
    155                  name_to_coefficient_map[name] = 0.0
    156               name_to_coefficient_map[name] += coefficient
     154              name_to_coefficient_map[name] = coefficient + name_to_coefficient_map.get(name,0.0)
    157155
    158156        sorted_names = sorted(name_to_coefficient_map.keys())
     
    169167            sign = '+'
    170168            if constant_term < 0: sign = '-'
    171             print >>OUTPUT, '%s%f %s' % (sign, math.fabs(offset), 'ONE_VAR_CONSTANT')
     169            print >>OUTPUT, '%s%f %s' % (sign, math.fabs(constant_term), 'ONE_VAR_CONSTANT')
    172170
    173171        return constant_term
Note: See TracChangeset for help on using the changeset viewer.