File: StatisticReader_SolvingTimeReader.py

package info (click to toggle)
scip 10.0.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 76,156 kB
  • sloc: ansic: 716,600; cpp: 41,095; awk: 9,195; sh: 4,918; makefile: 4,044; python: 2,076; perl: 731; xml: 660; java: 314; php: 24; lisp: 15
file content (45 lines) | stat: -rw-r--r-- 1,443 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from StatisticReader import StatisticReader

class SolvingTimeReader(StatisticReader):
   '''
   extracts the solving time
   '''
   name = 'SolvingTimeReader'
   regular_exp = 'Solving Time (sec) :'
   columnwidth = 12
   datakey = 'SolvingTime'
   columnheaderstr = 'Time(s)'.rjust(columnwidth)
    
   solvingtimereadkeys = {
      StatisticReader.SOLVERTYPE_SCIP : "Solving Time (sec) :",
      StatisticReader.SOLVERTYPE_CPLEX : "Solution time =",
      StatisticReader.SOLVERTYPE_GUROBI : "Explored ",
      StatisticReader.SOLVERTYPE_CBC : "Coin:Total time (CPU seconds):",
      StatisticReader.SOLVERTYPE_XPRESS : " *** Search "
   }
                   
   solvingtimelineindex = {
      StatisticReader.SOLVERTYPE_SCIP : -1,
      StatisticReader.SOLVERTYPE_CPLEX : 3,
      StatisticReader.SOLVERTYPE_GUROBI : -2,
      StatisticReader.SOLVERTYPE_CBC : 4,
      StatisticReader.SOLVERTYPE_XPRESS : 5
   }
    
   returned = False
   DEFAULT_SOLVINGTIME=3600.0

   def extractStatistic(self, line):
      if self.solvingtimereadkeys[StatisticReader.solvertype] in line:
         solvingtime = line.split()[self.solvingtimelineindex[StatisticReader.solvertype]]
         self.returned = True
         return float(solvingtime)
      else:
         return None

   def execEndOfProb(self):
      if not self.returned:
         return SolvingTimeReader.DEFAULT_SOLVINGTIME
      else:
         self.returned = False
         return None