Esempio n. 1
0
    def Sensitivity_Analysis(self):
        '''
        1. Simple filter: d
        '''
        global i, domains_to_filter, sensitivity_number, sensitivity_number_old
        print("Sensitivity_Analysis")

        for ft in filter_list:
            if ft[0] and ft[1]:
                if len(ft) == 2:
                    domains_to_filter = list(opt_domains)
                else:
                    domains_to_filter = []
                    for dn in ft[2:]:
                        domains_to_filter += domains[dn]
                if ft[0] == "simple":
                    sensitivity_number = beso_filters.run2(
                        file_name, sensitivity_number, weight_factor2,
                        near_elm, domains_to_filter)
                elif ft[0].split()[0] in [
                        "erode", "dilate", "open", "close", "open-close",
                        "close-open", "combine"
                ]:
                    if ft[0].split()[1] == "sensitivity":
                        domains_en_in_state = [[]] * number_of_states
                        for en in domains_to_filter:
                            sn = elm_states[en]
                            domains_en_in_state[sn].append(en)
                        for sn in range(number_of_states):
                            if domains_en_in_state[sn]:
                                sensitivity_number = beso_filters.run_morphology(
                                    sensitivity_number, near_elm,
                                    domains_en_in_state[sn], ft[0].split()[0])
        if filter_on_sensitivity == "over nodes":
            sensitivity_number = beso_filters.run1(
                file_name, sensitivity_number, weight_factor_node, M,
                weight_factor_distance, near_nodes, nodes, opt_domains)
        elif filter_on_sensitivity == "over points":
            sensitivity_number = beso_filters.run3(sensitivity_number,
                                                   weight_factor3, near_elm3,
                                                   near_points)

        if sensitivity_averaging:
            for en in opt_domains:
                # averaging with the last iteration should stabilize iterations
                if i > 0:
                    sensitivity_number[en] = (sensitivity_number[en] +
                                              sensitivity_number_old[en]) / 2.0
                sensitivity_number_old[en] = sensitivity_number[
                    en]  # for averaging in the next step
Esempio n. 2
0
                    domains_to_filter = list(opt_domains)
                else:
                    domains_to_filter = []
                    for dn in ft[2:]:
                        domains_to_filter += domains[dn]
                sensitivity_number = beso_filters.run2_casting(sensitivity_number, above_elm, below_elm,
                                                               domains_to_filter)
                continue  # to evaluate other filters
            if len(ft) == 2:
                domains_to_filter = list(opt_domains)
            else:
                domains_to_filter = []
                for dn in ft[2:]:
                    domains_to_filter += domains[dn]
            if ft[0] == "over points":
                sensitivity_number = beso_filters.run3(sensitivity_number, weight_factor3[kp], near_elm3[kp],
                                                       near_points[kp])
                kp += 1
            elif ft[0] == "over nodes":
                sensitivity_number = beso_filters.run1(file_name, sensitivity_number, weight_factor_node[kn], M[kn],
                                                       weight_factor_distance[kn], near_nodes[kn], nodes,
                                                       domains_to_filter)
                kn += 1
            elif ft[0] == "simple":
                sensitivity_number = beso_filters.run2(file_name, sensitivity_number, weight_factor2, near_elm,
                                                       domains_to_filter)
            elif ft[0].split()[0] in ["erode", "dilate", "open", "close", "open-close", "close-open", "combine"]:
                if ft[0].split()[1] == "sensitivity":
                    sensitivity_number = beso_filters.run_morphology(sensitivity_number, near_elm, domains_to_filter,
                                                                     ft[0].split()[0])

    if sensitivity_averaging:
Esempio n. 3
0
                if len(ft) == 3:
                    domains_to_filter = list(opt_domains)
                else:
                    domains_to_filter = []
                    for dn in ft[2:]:
                        domains_to_filter += domains[dn]
                sensitivity_number = beso_filters.run2_casting(sensitivity_number, above_elm, domains_to_filter)
                continue  # to evaluate other filters
            if len(ft) == 2:
                domains_to_filter = list(opt_domains)
            else:
                domains_to_filter = []
                for dn in ft[2:]:
                    domains_to_filter += domains[dn]
            if ft[0] == "over points":
                sensitivity_number = beso_filters.run3(sensitivity_number, weight_factor3[kp], near_elm3[kp],
                                                       near_points[kp])
                kp += 1
            elif ft[0] == "over nodes":
                sensitivity_number = beso_filters.run1(file_name, sensitivity_number, weight_factor_node[kn], M[kn],
                                                       weight_factor_distance[kn], near_nodes[kn], nodes,
                                                       domains_to_filter)
                kn += 1
            elif ft[0] == "simple":
                sensitivity_number = beso_filters.run2(file_name, sensitivity_number, weight_factor2, near_elm,
                                                       domains_to_filter)
            elif ft[0].split()[0] in ["erode", "dilate", "open", "close", "open-close", "close-open", "combine"]:
                if ft[0].split()[1] == "sensitivity":
                    sensitivity_number = beso_filters.run_morphology(sensitivity_number, near_elm, domains_to_filter,
                                                                     ft[0].split()[0])

    if sensitivity_averaging: