def parse(self, out, err):
        if out is None or out == '':
            return 'solver output is empty', None, None, None

        out_lines = [l.strip() for l in out.split('\n') if l.strip() != '']

        assignment_begin = get_index(out_lines, lambda s: s.startswith('sat') or s.startswith('unsat'))
        stats_begin = assignment_begin + get_index(out_lines[assignment_begin:], lambda s: s.startswith('['))
        out_wo_stats = '\n'.join(out_lines[assignment_begin:stats_begin])
        parse_error, is_sat, assignment, _ = self._boolector_parser.parse(out_wo_stats, err)

        if parse_error is not None:
            return parse_error, None, None, None

        nof_sat_calls_re = re.compile(r'\[picosat\] (\d+) calls')
        sat_time_re = re.compile(r'\[picosat\] (\d+\.?\d*) seconds in library')

        nof_sat_calls, sat_time = 0, 0

        nof_sat_calls_line = get_val(out_lines, nof_sat_calls_re.match)
        if nof_sat_calls_line is not None:
            nof_sat_calls = int(nof_sat_calls_re.match(nof_sat_calls_line).groups()[0])
            sat_time_line = get_val(out_lines, sat_time_re.match)
            sat_time = float(sat_time_re.match(sat_time_line).groups()[0])

        time = float(re.compile(r'\[btrmain\] (\d+.?\d*) seconds').match(out_lines[-2]).groups()[0])

        return None, is_sat, assignment, StatsData(time, sat_time, nof_sat_calls)
Example #2
0
    def parse(self, out, err):
        parse_error, is_sat, assignment, _ = self._stp_parser.parse(out, err)

        if parse_error is not None:
            return parse_error, None, None, None

        err_lines = [e.strip() for e in err.split('\n')]

        nof_sat_calls, sat_time = 0, 0

        sat_re = re.compile(r'SAT Solving: (\d+) \[(\d+)ms\]')
        sat_line = get_val(err_lines, sat_re.match)
        if sat_line is not None:
            m = sat_re.match(sat_line)
            nof_sat_calls_token, sat_time_token = m.groups()
            nof_sat_calls, sat_time = int(nof_sat_calls_token), float(sat_time_token)/1000.

        time_re = re.compile(r'Statistics Total: (\d+\.?\d*)')
        time_line = get_val(err_lines, time_re.match)
        time = float(time_re.match(time_line).groups()[0])

        return None, is_sat, assignment, StatsData(time, sat_time, nof_sat_calls)