Changeset 1908


Ignore:
Timestamp:
Nov 18, 2009 10:59:02 PM (12 years ago)
Author:
jwatson
Message:

Using symbol map in solver results output to print names that a user will actually recognize!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.opt/trunk/coopr/opt/results/old_results.py

    r1907 r1908  
    9999        return self._info.__iter__()
    100100
    101     def pprint(self, ostream=None):
     101    def pprint(self, ostream=None, symbol_map=None):
    102102        if ostream is None:
    103103           ostream = sys.stdout
     
    106106           flag=True
    107107           for (name,value) in self._info:
    108              if value != 0:
    109                 print >>ostream, "        "+str(name)+"\t"+format_io(value)
    110                 flag=False
     108              # translate the name, if a map is available and the
     109              # item is in the map.
     110              if (symbol_map is not None) and (name in symbol_map):
     111                 name=symbol_map[name]
     112              if value != 0:
     113                 print >>ostream, "        "+str(name)+"\t"+format_io(value)
     114                 flag=False
    111115           if flag:
    112116              print >>ostream,   "        No nonzero values"
     
    145149        setattr(self, "_"+name, _SolutionSuffix(description))
    146150
    147     def pprint(self, ostream=None, only_variables=False):
     151    def pprint(self, ostream=None, only_variables=False, symbol_map=None):
    148152        if ostream is None:
    149153           ostream = sys.stdout
     
    169173            if only_variables and item != "variable":
    170174                continue
    171             getattr(self,"_"+item).pprint(ostream=ostream)
     175            getattr(self,"_"+item).pprint(ostream=ostream, symbol_map=symbol_map)
    172176
    173177
     
    285289           i=0
    286290           while i<min(num, len(self.solution)):
    287              self.solution(i).pprint(ostream, only_variables=only_variables)
     291             self.solution(i).pprint(ostream, only_variables=only_variables, symbol_map=self.symbol_map)
    288292             i += 1
    289293        else:
Note: See TracChangeset for help on using the changeset viewer.