示例#1
0
def devide_until_valid_size_with_singularity(result, singularity, box):
    box1, box2 = box.split()
    if box1.is_valid_size():
        if jacobian.is_jacobian_deg(box1.coordinates):
            singularity = np.append(singularity, box1)
        else:
            result = np.append(result, np.array([box1]), 0)
    else:
        if jacobian.is_jacobian_deg(box1.coordinates):
            result, singularity = devide_until_valid_size_with_singularity(
                result, singularity, box1)
        else:
            result = devide_until_valid_size(result, box1)
#        print("box1 ")
#        box1.print_box_only()
    if box2 is not None:
        if box2.is_valid_size():
            if jacobian.is_jacobian_deg(box2.coordinates):
                singularity = np.append(singularity, box2)
            else:
                result = np.append(result, np.array([box2]), 0)
        else:
            #            print("box2 ")
            #            box2.print_box_only()
            if jacobian.is_jacobian_deg(box2.coordinates):
                result, singularity = devide_until_valid_size_with_singularity(
                    result, singularity, box2)
            else:
                result = devide_until_valid_size(result, box2)
    return result, singularity
示例#2
0
def calculate_with_singularity(result, singularity, box):
    if box.is_valid_size():
        return check_valid_size_with_singularity(result, singularity, box)
    all_valid = True
    all_notvalid = True
    for i in range(4):
        r = True
        if box.checks[i] == -1:
            r = False
        elif box.checks[i] == 1:
            r = True
        else:
            r = inverse_problem(box.get_angle_box(i))
            box.checks[i] = 1 if r else -1
        if r:
            all_notvalid = False
        else:
            all_valid = False
    if all_notvalid:
        if box.how_many_valid_size() > 5:
            if not optimization(box):
                return result, singularity
    elif all_valid:
        return devide_until_valid_size_with_singularity(
            result, singularity, box)
    box1, box2 = box.split()
    result, singularity = calculate_with_singularity(result, singularity, box1)
    if box2 is not None:
        result, singularity = calculate_with_singularity(
            result, singularity, box2)
    return result, singularity
示例#3
0
def start_divide(result, box):
    if box.is_valid_size():
        return check_valid_size(result, box)
    all_valid = True
    all_notvalid = True
    for i in range(8):
        r = True
        if box.checks[i] == -1:
            r = False
        elif box.checks[i] == 1:
            r = True
        else:
            r = inverse_problem(box.get_angle_box(i))
            box.checks[i] = 1 if r else -1
        if r:
            all_notvalid = False
        else:
            all_valid = False
    if all_notvalid:
        if box.how_many_valid_size() > 5:
            if not optimization(box):
                return result
    elif all_valid:
        return devide_until_valid_size(result, box)
    box1, box2 = box.split()
    result = start_divide(result, box1)
    if box2 is not None:
        result = start_divide(result, box2)
    return result
示例#4
0
def devide_until_valid_size(result, box):
    box1, box2 = box.split()
    if box1.is_valid_size():
        result = np.append(result, np.array([box1]), 0)
    else:
        #        box1.print_box_only("box1")
        result = devide_until_valid_size(result, box1)
    if box2 is not None:
        if box2.is_valid_size():
            result = np.append(result, np.array([box2]), 0)
        else:
            #            box2.print_box_only("box2")
            result = devide_until_valid_size(result, box2)
    return result