예제 #1
0
class ComparatorPnml(object):

    def __init__(self, filename, nfilename=None,
            max_coef=10, smt_timeout_iter=0, smt_timeout_matrix=0,
            positive_log=None):
        self.filename = filename
        parser = PnmlParser(filename)
        parser.parse()
        self.net = parser.petrinet
        self.dim = parser.dim
        self.event_dictionary = parser.event_dictionary
        self.positive_log = positive_log

        # Helper pach. Doesn't actually compute hull
        self.pach = PacH(filename, nfilename=nfilename)
        self.pach.event_dictionary = parser.event_dictionary
        self.pach.dim = self.dim
        self.pach.reversed_dictionary = rotate_dict(parser.event_dictionary)
        if nfilename:
            self.pach.parse_negatives()

        #qhull = self.net.get_qhull()
# TODO WTF!?
        qhull = self.net.get_qhull(neg_points=self.pach.npv_set)
        qhull.prepare_negatives()
        # Hull for NO SMT
        qhull_no_smt = copy.deepcopy(qhull)
        # Hull for SMT iterative simp
        qhull_smt_iter = copy.deepcopy(qhull)
        # Hull for SMT matrix simp
        qhull_smt_matrix = qhull

        self.comparator = Comparator(qhull_no_smt, qhull_smt_iter, qhull_smt_matrix,
                max_coef, smt_timeout_iter, smt_timeout_matrix)

    def generate_pnml(self):
        output_pnml = self.filename
        output_pnml = (output_pnml.endswith('.pnml') and output_pnml[:-5])\
                or output_pnml or ''
        return self.comparator.generate_pnml(filename=output_pnml,
                reversed_dictionary=self.pach.reversed_dictionary)

    def compare(self):
        return self.comparator.compare()

    def generate_outputs(self):
        # For every benchmark, generate the output
        return self.comparator.generate_outputs(pach=self.pach)

    def check_hull(self):
        if self.positive_log:
            return self.comparator.check_hull(log_file=self.positive_log,
                    event_dictionary=self.event_dictionary)
예제 #2
0
class ComparatorXes(object):

    def __init__(self, filename,
            samp_num=1, samp_size=None,
            proj_size=None, proj_connected=True,
            nfilename=None, max_coef=10,
            smt_timeout_iter=0,
            smt_timeout_matrix=0,
            sanity_check=False):
        self.pach = PacH(filename,
            samp_num=samp_num, samp_size=samp_size,
            proj_size=proj_size, proj_connected=proj_connected,
            nfilename=nfilename, max_coef=max_coef,
            sanity_check=sanity_check)
        self.pach.parse()

        qhull = self.pach.qhull
        # Hull for NO SMT
        qhull_no_smt = copy.deepcopy(qhull)
        # Hull for SMT iterative simp
        qhull_smt_iter = copy.deepcopy(qhull)
        # Hull for SMT matrix simp
        qhull_smt_matrix = copy.deepcopy(qhull)

        self.comparator = Comparator(qhull_no_smt, qhull_smt_iter, qhull_smt_matrix,
                max_coef, smt_timeout_iter, smt_timeout_matrix)

    def generate_pnml(self):
        return self.comparator.generate_pnml(filename=self.pach.filename,
                reversed_dictionary=self.pach.reversed_dictionary)

    def compare(self,log_file='', event_dictionary={}):
        return self.comparator.compare(log_file=log_file, event_dictionary=event_dictionary)

    def generate_outputs(self):
        # For every benchmark, generate the output
        qhull = self.comparator.qhull_no_smt
        self.pach.output.get('times',{}).update(qhull.output.get('times',{}))
        self.pach.qhull = qhull
        self.pach.smt_matrix = False
        self.pach.smt_iter = False
        # Force initial complexity for effectiveness calculation
        self.pach.initial_complexity = self.comparator.no_smt_initial_complexity
        self.pach.generate_output_file()
        logger.info('Generated output for NO SMT simplification')
        qhull = self.comparator.qhull_smt_iter
        self.pach.output.get('times',{}).update(qhull.output.get('times',{}))
        self.pach.qhull = qhull
        self.pach.smt_matrix = False
        self.pach.smt_iter = True
        # Force initial complexity for effectiveness calculation
        self.pach.initial_complexity = self.comparator.iter_initial_complexity
        self.pach.generate_output_file()
        logger.info('Generated output for Iterative SMT simplification')
        qhull = self.comparator.qhull_smt_matrix
        self.pach.output.get('times',{}).update(qhull.output.get('times',{}))
        self.pach.qhull = qhull
        self.pach.smt_matrix = True
        self.pach.smt_iter = False
        # Force initial complexity for effectiveness calculation
        self.pach.initial_complexity = self.comparator.matrix_initial_complexity
        self.pach.generate_output_file()
        logger.info('Generated output for Matrix SMT simplification')
        return True