def estimating_r(components, upper_bound=1000): r_bounds = [[upper_bound, 0]] * (len(components[0][0]) - 2) r_list = [] y_list = [] for box1 in components[0]: for box2 in components[1]: y_list.append( [0.5 * (q1 + q2) for q1, q2 in zip(box1[2:], box2[2:])]) norm_q1q2 = d.distance(box1[2:], box2[2:]) q1q2 = [box1[i] - box2[i] for i in range(2, len(box1))] r = [ri / norm_q1q2 for ri in q1q2] r_list.append(r) r = [] y = [] for i in range(len(y_list[0])): yi1 = min([float(y[i].lower()) for y in y_list]) yi2 = max([float(y[i].upper()) for y in y_list]) y.append([yi1, yi2]) for i in range(len(r_list[0])): ri1 = min([float(r[i].lower()) for r in r_list]) ri2 = max([float(r[i].upper()) for r in r_list]) r.append([ri1, ri2]) return y + r
def estimating_t(components, upper_bound=19.8): #it works only if len(components) t1 = upper_bound t2 = 0 for box1 in components[0]: for box2 in components[1]: a = d.distance(box1, box2).lower() b = d.distance(box1, box2).upper() if t1 > a: t1 = a if t2 < b: t2 = b t = d.ftconstructor(t1, t2) t = 0.25 * d.power_interval(t, 2) return [float(t.lower()), float(t.upper())]
def estimating_r(components): r31 = 5 r32 = 0 r41 = 5 r42 = 0 for box1 in components[0]: for box2 in components[1]: norm_q1q2 = d.distance(box1[2:], box2[2:]) q1q2 = [box1[i] - box2[i] for i in range(2, len(box1))] r3, r4 = [ri / norm_q1q2 for ri in q1q2] if r31 > r3.lower(): r31 = float(r3.lower()) if r32 < r3.upper(): r32 = float(r3.upper()) if r41 > r4.lower(): r41 = float(r4.lower()) if r42 < r4.upper(): r42 = r4.upper() return [[r31, r32], [r41, r42]]