示例#1
0
    def detect_parallel_cut(self, orig_conn_components, this_nx_graph,
                            strongly_connected_components):
        """
        Detects parallel cut

        Parameters
        --------------
        orig_conn_components
            Connected components of the graph
        this_nx_graph
            NX graph calculated on the DFG
        strongly_connected_components
            Strongly connected components
        """
        conn_components = get_connected_components(
            self.negated_ingoing,
            self.negated_outgoing,
            self.activities,
            force_insert_missing_acti=False)

        if len(conn_components) > 1:
            if self.check_par_cut(conn_components, this_nx_graph,
                                  strongly_connected_components):
                return [True, conn_components]

        return [False, []]
示例#2
0
    def detect_concurrent_cut(self):
        """
        Detects concurrent cut
        """
        if len(self.dfg) > 0:
            conn_components = get_connected_components(self.ingoing,
                                                       self.outgoing,
                                                       self.activities)

            if len(conn_components) > 1:
                return [True, conn_components]

        return [False, []]
示例#3
0
    def detect_parallel_cut(self):
        """
        Detects parallel cut
        """
        conn_components = get_connected_components(
            self.negated_ingoing,
            self.negated_outgoing,
            self.activities,
            force_insert_missing_acti=False)

        if len(conn_components) > 1:
            if self.check_par_cut(conn_components):
                return [True, conn_components]

        return [False, []]
示例#4
0
    def detect_cut(self, second_iteration=False):
        """
        Detect generally a cut in the graph (applying all the algorithms)
        """
        if self.dfg:
            # print("\n\n")
            conn_components = get_connected_components(self.ingoing,
                                                       self.outgoing,
                                                       self.activities)
            this_nx_graph = None
            strongly_connected_components = None

            conc_cut = self.detect_concurrent_cut(
                conn_components, this_nx_graph, strongly_connected_components)
            seq_cut = self.detect_sequential_cut(
                conn_components, this_nx_graph, strongly_connected_components)
            par_cut = self.detect_parallel_cut(conn_components, this_nx_graph,
                                               strongly_connected_components)
            loop_cut = self.detect_loop_cut(conn_components, this_nx_graph,
                                            strongly_connected_components)

            if conc_cut[0]:
                for comp in conc_cut[1]:
                    new_dfg = filter_dfg_on_act(self.dfg, comp)
                    self.detected_cut = "concurrent"
                    self.children.append(
                        Subtree(new_dfg,
                                self.master_dfg,
                                self.initial_dfg,
                                comp,
                                self.counts,
                                self.rec_depth + 1,
                                noise_threshold=self.noise_threshold,
                                initial_start_activities=self.
                                initial_start_activities,
                                initial_end_activities=self.
                                initial_end_activities))
            else:
                if seq_cut[0]:
                    self.detected_cut = "sequential"
                    for child in seq_cut[1]:
                        dfg_child = filter_dfg_on_act(self.dfg, child)
                        self.children.append(
                            Subtree(dfg_child,
                                    self.master_dfg,
                                    self.initial_dfg,
                                    child,
                                    self.counts,
                                    self.rec_depth + 1,
                                    noise_threshold=self.noise_threshold,
                                    initial_start_activities=self.
                                    initial_start_activities,
                                    initial_end_activities=self.
                                    initial_end_activities))
                else:
                    if par_cut[0]:
                        union_acti_comp = set()
                        for comp in par_cut[1]:
                            union_acti_comp = union_acti_comp.union(comp)
                        diff_acti_comp = set(
                            self.activities).difference(union_acti_comp)

                        for act in diff_acti_comp:
                            par_cut[1] = add_to_most_probable_component(
                                par_cut[1], act, self.ingoing, self.outgoing)

                        for comp in par_cut[1]:
                            new_dfg = filter_dfg_on_act(self.dfg, comp)
                            self.detected_cut = "parallel"
                            self.children.append(
                                Subtree(new_dfg,
                                        self.master_dfg,
                                        new_dfg,
                                        comp,
                                        self.counts,
                                        self.rec_depth + 1,
                                        noise_threshold=self.noise_threshold,
                                        initial_start_activities=self.
                                        initial_start_activities,
                                        initial_end_activities=self.
                                        initial_end_activities))
                    else:
                        if loop_cut[0]:
                            self.detected_cut = "loopCut"
                            for child in loop_cut[1]:
                                dfg_child = filter_dfg_on_act(self.dfg, child)
                                self.children.append(
                                    Subtree(
                                        dfg_child,
                                        self.master_dfg,
                                        self.initial_dfg,
                                        child,
                                        self.counts,
                                        self.rec_depth + 1,
                                        noise_threshold=self.noise_threshold,
                                        initial_start_activities=self.
                                        initial_start_activities,
                                        initial_end_activities=self.
                                        initial_end_activities))
                        else:
                            if self.noise_threshold > 0:
                                if not second_iteration:
                                    self.initialize_tree(self.dfg,
                                                         self.initial_dfg,
                                                         None,
                                                         second_iteration=True)
                            else:
                                pass
                            self.detected_cut = "flower"
        else:
            self.detected_cut = "base_concurrent"