Exemplo n.º 1
0
def checking_assumptions(
        curve_data):  #the input of this function is the output of Ball_solver
    if len(curve_data[0][1]) != 0:
        return 0
    Ball_sols_ft = [[d.ftconstructor(Bi[0], Bi[1]) for Bi in B]
                    for B in curve_data[1][0]
                    ] + [[d.ftconstructor(Bi[0], Bi[1]) for Bi in B]
                         for B in curve_data[1][1]]
    alph3 = assum_alph3_checker(Ball_sols_ft)
    if alph3 == 1:
        return 1
    else:
        return 0
Exemplo n.º 2
0
def detecting_nodes(boxes, B):  #boxes are list of cer and uncer curve
    mixes_boxes = [[1, box] for box in boxes[0]] + [
        [0, box] for box in boxes[1]
    ]  #putting flaggs for cer and uncer boxes
    ftboxes = [[
        box[0], [d.ftconstructor(boxi[0], boxi[1]) for boxi in box[1]]
    ] for box in mixes_boxes]
    nodes_lifting = []
    used = []
    for i in range(len(ftboxes)):
        for j in range(i + 1, len(ftboxes)):
            if d.boxes_intersection(ftboxes[1][i],ftboxes[1][j]) ==[] and \
             d.boxes_intersection(ftboxes[1][i][:2],ftboxes[1][j][:2]) :
                if i not in used:
                    used.append(i)
                    nodes_lifting.append(ftboxes[i])
                if j not in used:
                    used.append(j)
                    nodes_lifting.append(ftboxes[j])
    components = planner_connected_compnants(nodes_lifting)
    cer_components = []
    uncer_components = []
    for component in components:
        if 0 in [box[0] for box in component]:
            cer_components.append([box[1] for box in component])
        else:
            uncer_components.append([box[1] for box in component])
    return [cer_components, uncer_components]
Exemplo n.º 3
0
def filtering_twins(solutions):
    n = len(solutions[0])
    ftsolutions = [[d.ftconstructor(boxi[0], boxi[1]) for boxi in box]
                   for box in solutions]
    twin = [[]] * len(solutions)
    for i in range(len(solutions)):
        for j in range(i + 1, len(solutions)):
            if boxes_intersection(ftsolutions[i][:n],ftsolutions[j][:n]) !=[] \
            and  boxes_intersection(ftsolutions[i][n:], [-box for box in  ftsolutions[j][n:]]) !=[]:
                twin[i].append(j)
                twin[j].append(i)
    return twin
def Ball_solver(equations, B_Ball, X):  #the width condition needs to be added
    L = [B_Ball]
    certified_boxes = []
    uncertified_boxes = []
    n = len(X)
    while len(L) != 0:

        solvability = 1
        if B_Ball[2*n-2][0] <= 0 <=   B_Ball[2*n-2][1] and \
        d.width([ d.ftconstructor(Bi[0],Bi[1]) for Bi in L[0] ] ) <0.1 :
            Ball_cusp_gen(equations, B_Ball, X)
        elif (B_Ball[2*n-2][0] > 0 or 0 >   B_Ball[2*n-2][1] ) \
        and d.width([ d.ftconstructor(Bi[0],Bi[1]) for Bi in L[0] ] ) <0.1:
            Ball_node_gen(equations, B_Ball, X)
        else:
            children = cb.plane_subdivision(L[0])
            L.remove(L[0])
            L += children
            solvability = 0
        if solvability == 1:
            ibex_output = cb.solving_with_ibex()
            if ibex_output[0] == "Empty":

                L.remove(L[0])
            elif len(ibex_output[0]) != 0:

                certified_boxes += cb.computing_boxes(ibex_output[0])
                L.remove(L[0])
            elif len(ibex_output[1]) != 0:

                uncertified_boxes += cb.computing_boxes(ibex_output[1])
                L.remove(L[0])
            else:
                children = cb.plane_subdivision(L[0])
                L.remove(L[0])
                L += children

    return [certified_boxes, uncertified_boxes]
Exemplo n.º 5
0
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())]
Exemplo n.º 6
0
def connected_compnants(boxes):
    ftboxes = [[d.ftconstructor(boxi[0], boxi[1]) for boxi in box]
               for box in boxes]
    components = [[ftboxes[0]]]
    for i in range(1, len(ftboxes)):
        boxi_isused = 0
        for j in range(len(components)):
            membership = 0
            for k in range(len(components[j])):
                if d.boxes_intersection(ftboxes[i], components[j][k]) != []:
                    components[j].append(ftboxes[i])
                    membership = 1
                    boxi_isused = 1
                    break

            if membership == 1:
                break
        if boxi_isused == 0:
            components.append([ftboxes[i]])
    return components
Exemplo n.º 7
0
def detecting_nodes(boxes, B, f, X):  #boxes are list of cer and uncer curve
    mixes_boxes = [[1, box] for box in boxes[0]] + [
        [0, box] for box in boxes[1]
    ]  #putting flaggs for cer and uncer boxes

    ftboxes = [[
        box[0], [d.ftconstructor(boxi[0], boxi[1]) for boxi in box[1]]
    ] for box in mixes_boxes]

    nodes_lifting = []
    used = []
    for i in range(len(ftboxes)):
        for j in range(i + 1, len(ftboxes)):
            if d.boxes_intersection(ftboxes[i][1],ftboxes[j][1]) ==[] and \
             d.boxes_intersection(ftboxes[i][1][:2],ftboxes[j][1][:2]) :
                if i not in used:
                    used.append(i)
                    nodes_lifting.append(ftboxes[i])
                if j not in used:
                    used.append(j)
                    nodes_lifting.append(ftboxes[j])

    components = planner_connected_compnants(nodes_lifting)
    cer_components = []
    uncer_components = []
    component_normal = []
    for component in components:
        boxes_component = [box[1] for box in component]
        component_normal = [[[float(Bi.lower()),
                              float(Bi.upper())] for Bi in box[1]]
                            for box in component]
        if 0 not in [box[0] for box in component] and eval_file_gen(
                f, component_normal, X) == "[]\n":
            cer_components.append(boxes_component)
        else:
            uncer_components.append(boxes_component)
    return [cer_components, uncer_components]
Exemplo n.º 8
0
def plane_subdivision(B):

    ft_B2 = d.subdivide([d.ftconstructor(Bi[0], Bi[1]) for Bi in B[:2]])
    normal_B2 = [d.ft_normal(Bi) for Bi in ft_B2]
    return d.cartesian_product(normal_B2, [B[2:]])
Exemplo n.º 9
0
def normal_subdivision(B):
    ft_B = d.subdivide([d.ftconstructor(Bi[0], Bi[1]) for Bi in B[:]])
    return [d.ft_normal(Bi) for Bi in ft_B]
Exemplo n.º 10
0
        Pi=Pi.replace("^","**")
        S1.append(parse_expr(Pi))    

jac=sympy.Matrix(S1).jacobian(sympy.Matrix(X)) 
eval_jac=jac.subs([(x1,0.9207659841484748),(x2,6.176745907220626),(q1,1.422816280529649),\
    (q2,1.60413583605439),(r3,1),(r4,0)])
input()"""

f = "boxes_first_branch_silhouette"

b = [[4, 5], [11.9, 12.4], [-3.15, 3.15], [-3.15, 3.15], [-1, 1], [-1, 1],
     [0.1, 9.2]]
T = intersting_boxes(f, b)[0]

sorted = boxes_sort(T)
T = [[d.ftconstructor(Tij[0], Tij[1]) for Tij in Ti] for Ti in T]
components = connected_compnants(sorted)
print(len(components))
t = estimating_t(components)
r = estimating_r(components)

input()

S = finding_nodes(P, b[0], b[1], [t[0], t[1]])

fig, ax = plt.subplots()
plt.grid(True)
ax.set_xlim(-3, 3)
ax.set_ylim(-3, 3)
#plt.xticks(np.arange(-20, 20, 2.0))
#plt.yticks(np.arange(-20, 20, 2.0))
Exemplo n.º 11
0
import flint as ft 
import sympy as sp 
import draft as d 
def eval_func():
  pass 
boxes=[[[-0.009913982108861342, -0.0025158218616127435], [3.00503940841096, 3.019805054981555], [1.5714252840296008, 1.5732748255538804]], [[-0.0042373384016543255, 0.005435537798402309], [2.9915357528894244, 3.0108605107175688], [-1.5718556596522972, -1.5694374440838288]], [[-0.002524768433437398, 0.008492953862509044], [2.9830193374427036, 3.005041025468847], [1.5686730898987435, 1.5714275167801817]]]
ftboxes=[ [d.ftconstructor(Bi[0],Bi[1]) for Bi in B ] for B in boxes ] 
n=len(boxes[0])
m=len(boxes)
m1=[]
m2=[]
for B in ftboxes: 
   m1.append((-ft.arb.sin(B[2])**4 - 3)*ft.arb.sin(B[2]) + 4*ft.arb.sin(B[2])**3*ft.arb.cos(B[2])**2) 
   m2.append(-2*(ft.arb.sin(8*B[2]) + 3)*ft.arb.sin(B[2])*ft.arb.cos(B[2]) - 8*ft.arb.sin(B[2])**2*ft.arb.cos(8*B[2])) 
innrer_loops=[i for i in range(m) if 0 in m1[i] and 0 in m2[i] ]
print(innrer_loops)