Changeset 2228


Ignore:
Timestamp:
Feb 1, 2010 4:49:40 PM (10 years ago)
Author:
jwatson
Message:

Final fix to LP writer to (optionally) account for the models in which a variable originates - the PySP extensive form writer now passes all tests.

File:
1 edited

Legend:

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

    r2214 r2228  
    100100            for id in keys:
    101101                coef = x[1][id]
    102                 name = convert_name(x[-1][id.keys()[0]].label)
     102                prefix = ""
     103                if self._output_prefixes is True:
     104                   parent_var = x[-1][id.keys()[0]].var
     105                   prefix = convert_name(parent_var.model.name) + "_"
     106                name = prefix + convert_name(x[-1][id.keys()[0]].label)
    103107                print >>OUTPUT, ('- %f' % math.fabs(coef) if coef < 0.0 else '+ %f' % coef), name,
    104108                terms_output += 1
     
    117121                print >>OUTPUT, ('- %f' % math.fabs(coef) if coef < 0.0 else '+ %f' % coef),
    118122                for var in id:
    119                     name = convert_name(x[-1][var].label)
     123                    prefix = ""
     124                    if self._output_prefixes is True:
     125                       parent_var = x[-1][var].var
     126                       prefix = convert_name(parent_var.model.name) + "_"
     127                    name = prefix + convert_name(x[-1][var].label)
    120128                    if id[var] > 1:
    121129                        print "%s^%d" % (name,id[var]),
Note: See TracChangeset for help on using the changeset viewer.