Changeset 2907


Ignore:
Timestamp:
Aug 3, 2010 3:08:18 PM (9 years ago)
Author:
prsteel
Message:

The cpxlp writer did not allow constant objectives to be printed
out, which precluded solving feasibility problems. Changed the
behavior to output "obj: +0.0 ONE_VAR_CONSTANT" since that dummy
variable was already acting in a similar fashion as a placeholder for
empty constraint blocks.

Note that this does introduce "ONE_VAR_CONSTANT" as a 'variable' in
the result object of problems involving constant objectives. If this
should cause issues with users parsing the result objects, we can
teach them to ignore "ONE_VAR_CONSTANT" entries.

File:
1 edited

Legend:

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

    r2901 r2907  
    376376           for key in obj_keys:
    377377                if is_constant(obj[key].repn):
    378                     msg = 'WARNING: ignoring objective %s%s which is constant'
    379                     if key is None: msg %= (obj.name, '')
    380                     else:           msg %= (obj.name, key)
    381 
    382                     print msg
     378
     379                    print ("Warning: Constant objective detected, replacing " +
     380                           "with a placeholder to prevent solver failure.")
     381                   
     382                    line = "obj: +0.0 ONE_VAR_CONSTANT\n"
     383                    print >>OUTPUT, self.wrapper.fill(line)
     384
     385                    # Skip the remaining logic of the section
    383386                    continue
    384387
Note: See TracChangeset for help on using the changeset viewer.