Ignore:
Timestamp:
Jan 24, 2010 4:06:15 PM (10 years ago)
Author:
jwatson
Message:

Added a _report_timing attribute to the base solver class. If true, it will print out presolve/solve/postsolve timing statistics. The derived shell-based solver will additionally report log and solution file read times.

File:
1 edited

Legend:

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

    r2033 r2167  
    2424import pyutilib.common
    2525import pyutilib.misc
     26
     27import time
    2628
    2729
     
    126128        self.problem=None
    127129        self._assert_available=False
     130        self._report_timing = False # timing statistics are always collected, but optionally reported.
    128131
    129132        # a fairly universal solver feature, at least when dealing
     
    151154    def solve(self, *args, **kwds):
    152155        """ Solve the problem """
     156        initial_time = time.time()
    153157        self._presolve(*args, **kwds)
     158        presolve_completion_time = time.time()
    154159        self._apply_solver()
     160        solve_completion_time = time.time()
    155161        result = self._postsolve()
     162        postsolve_completion_time = time.time()
    156163        result.symbol_map = self._symbol_map
     164        if self._report_timing is True:
     165           print "Presolve time="+str(presolve_completion_time-initial_time)
     166           print "Solve time="+str(solve_completion_time - presolve_completion_time)
     167           print "Postsolve time="+str(postsolve_completion_time-solve_completion_time)
    157168        return result
    158169
Note: See TracChangeset for help on using the changeset viewer.