Changeset 1938


Ignore:
Timestamp:
Nov 23, 2009 1:07:50 PM (10 years ago)
Author:
wehart
Message:

Changes to clarify what solver outputs entail. Now, logfiles
are processed whenever available, and other data is processed with
an appropriate reader. The exception is 'soln' files, which
generically refers to solver-specific solution results. These are
parsed with a solver method.

Location:
coopr.opt/trunk/coopr/opt
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • coopr.opt/trunk/coopr/opt/base/formats.py

    r1897 r1938  
    3232
    3333#
     34# osrl - osrl XML file defined by the COIN-OR OS project
     35# results - A Pyomo results object  (reader define by solver class)
    3436# sol - AMPL *.sol file
    35 # osrl - osrl XML file defined by the COIN-OR OS project
    36 # log - An unformated logfile
    37 # results - A coopr.opt.SolverResults object
     37# soln - A solver-specific solution file  (reader define by solver class)
     38# yaml - A Pyomo results file in YAML format
    3839#
    39 ResultsFormat = Enum('sol', 'osrl', 'log', 'results')
     40ResultsFormat = Enum('osrl', 'results', 'sol', 'soln', 'yaml')
    4041
    4142
     
    4849    formats['lp']=ProblemFormat.cpxlp
    4950    formats['sol']=ResultsFormat.sol
    50     formats['log']=ResultsFormat.log
     51    formats['osrl']=ResultsFormat.osrl
     52    formats['soln']=ResultsFormat.soln
     53    formats['yaml']=ResultsFormat.yaml
     54    formats['results']=ResultsFormat.yaml
    5155    for fmt in formats:
    5256        if filename.endswith('.'+fmt):
  • coopr.opt/trunk/coopr/opt/base/solver.py

    r1918 r1938  
    176176        #if self._results_format not in self._valid_result_formats[self._problem_format]:
    177177        #   raise ValueError, "Results format `"+str(self._results_format)+"' cannot be used with problem format `"+str(self._problem_format)+"' in solver "+self.name
    178         if self._results_format == ResultsFormat.log:
     178        if self._results_format == ResultsFormat.soln:
    179179            self.results_reader = None
    180180        else:
  • coopr.opt/trunk/coopr/opt/reader/res.py

    r1918 r1938  
    2929
    3030    def __init__(self):
    31         results.AbstractResultsReader.__init__(self,ResultsFormat.results)
     31        results.AbstractResultsReader.__init__(self,ResultsFormat.yaml)
    3232
    3333    def __call__(self, filename, res=None, soln=None):
     
    4242
    4343
    44 results.ReaderRegistration(str(ResultsFormat.results), ResultsReader_results)
     44results.ReaderRegistration(str(ResultsFormat.yaml), ResultsReader_results)
    4545
  • coopr.opt/trunk/coopr/opt/results/results.py

    r1918 r1938  
    128128    def read(self, **kwds):
    129129        if not yaml_available:
    130             print "Aborting SolverResults.read() because PyYAML is not installed!"
    131             return
     130            raise IOError, "Aborting SolverResults.read() because PyYAML is not installed!"
    132131
    133132        if 'istream' in kwds:
  • coopr.opt/trunk/coopr/opt/solver/shellcmd.py

    r1772 r1938  
    6464        Process the logfile for information about the optimization process.
    6565        """
    66         raise NotImplementedError       #pragma:nocover
     66        return SolverResults()
    6767
    68     def process_other_data(self,results):
     68    def process_soln_file(self,results):
    6969        """
    7070        Process auxilliary data files generated by the optimizer (e.g. solution files)
    7171        """
    72         pass        #pragma:nocover
     72        return results
    7373
    7474    def _executable(self):
     
    176176        if self._results_format is None:
    177177           raise ValueError, "Results format is None"
     178        results = self.process_logfile()
    178179        if self.results_reader is None:
    179            if self._results_format is ResultsFormat.log:
    180               results = self.process_logfile()
    181            else:
    182               raise ValueError, "Results format `"+str(self._results_format)+"' is has not been registered"
     180           self.process_soln_file(results)
    183181        else:
    184            results = self.results_reader(self.results_file)
    185         self.process_other_data(results)
     182           results = self.results_reader(self.results_file, res=results)
    186183        if rc != None:
    187184           results.solver.error_rc=rc
     
    194191            formats.
    195192        """
    196         return ResultsFormat.log
     193        return ResultsFormat.soln
    197194
    198195
  • coopr.opt/trunk/coopr/opt/tests/base/test_factory.py

    r1768 r1938  
    127127        ans = coopr.opt.ReaderFactory()
    128128        self.failUnlessEqual(len(ans),4)
    129         self.failUnlessEqual(set(ans), set(["osrl","rtest", "sol","results"]))
     129        self.failUnlessEqual(set(ans), set(["osrl","rtest", "sol","yaml"]))
    130130
    131131    def test_reader_instance(self):
Note: See TracChangeset for help on using the changeset viewer.