Changeset 2982


Ignore:
Timestamp:
Aug 30, 2010 11:09:28 AM (9 years ago)
Author:
jwatson
Message:

Improving the speed of the cplex direct solver plugin.

File:
1 edited

Legend:

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

    r2981 r2982  
    105105       pairs = []
    106106
    107        keys = expression[1].keys()
    108        keys.sort()
    109        for id in keys:
    110           variable = expression[-1][id.keys()[0]].label # ugly way to get this.         
    111           coefficient = expression[1][id]
     107       hash_to_variable_map = expression[-1]
     108
     109       for variable_hash, coefficient in expression[1].iteritems():
     110
     111          variable_hash_iter = variable_hash.iterkeys()
     112          variable_name = hash_to_variable_map[variable_hash_iter.next()].label
    112113
    113114          if as_pairs is True:
    114              pairs.append((variable,coefficient))
     115             pairs.append((variable_name, coefficient))
    115116          else:
    116              variables.append(variable)
     117             variables.append(variable_name)
    117118             coefficients.append(coefficient)
    118119
Note: See TracChangeset for help on using the changeset viewer.