Ejemplo n.º 1
0
def draw_BZ_edge(ax, rec_lat_mat, color=None, ls_list=None, diff=0):
    """ tool_tip_missing
    """
    color = color or 'k'

    A, b = get_dd_matrix(rec_lat_mat)
    p = Hrep(A, b)
    verts = p.generators
    edges = get_edge(p.adj)
    # print 'number of vertices:', len(verts)
    draw_edges(ax, verts, edges, color, ls_list, diff=diff)
    def Draw_Mu4_Outline(self):

        A_matrix, b_vector = self.Obtain_Mu4_Outline_Inequalities()

        phasediagram_projection2d = Hrep(
            A_matrix, b_vector)  # H-representation of Ax <= b

        self.Draw_Mu4_Outline_Region(phasediagram_projection2d.generators,
                                     phasediagram_projection2d.ininc,
                                     phasediagram_projection2d.adj)

        self.quaternary_phasediagram_3d_plot_canvas.draw()
Ejemplo n.º 3
0
 def __init__(self, points = None, rays = None, A = None, b = None):
     have_rep = False
     if points is not None or rays is not None:
         self.vrep = Vrep(points, rays)
         self.hrep = Hrep(self.vrep.A, self.vrep.b)
         have_rep = True
     if A is not None and b is not None:
         self.hrep = Hrep(A, b)
         have_rep = True
     if not have_rep:
         raise RuntimeError('Must provide either generators or constraint'+
                            'matrix')
     self.ray_indices = []
     for i in range(len(self.hrep.generators)):
         if not self.hrep.is_vertex[i]:
             self.ray_indices.append(i)
     self.min_point = None
     self.max_point = None
     self.xlim = None
     self.ylim = None
     self.fig = None
     self.ax = None
Ejemplo n.º 4
0
def draw_pd(ax, file):
    """ tool_tip_missing
    """
    A, b, elements, sec_phases, mu_dep, dep_elem = read_cplap_input(file)

    p = Hrep(A, b)

    draw_plane(ax, p.generators, p.ininc, p.adj, sec_phases)
    write_vert_output(p.generators, p.inc, elements, sec_phases, mu_dep, dep_elem)
    write_half_output(p.generators, p.ininc, elements, sec_phases, mu_dep, dep_elem)

    set_axis(ax, A, b, elements)
    return p.generators
    def Draw_PhaseDiagram3D(self):

        A_matrix, b_vector, compounds_list = self.Obtain_Quaternary_PhaseDiagram3D_Inequalities(
        )

        phasediagram_polyhedron = Hrep(A_matrix,
                                       b_vector)  # H-representation of Ax <= b

        self.Draw_PhaseDiagram_Planes(phasediagram_polyhedron.generators,
                                      phasediagram_polyhedron.ininc,
                                      phasediagram_polyhedron.adj,
                                      compounds_list)

        self.Activate_PhaseDiagram3D_Plot_Axes()

        self.quaternary_phasediagram_3d_plot_canvas.draw()
Ejemplo n.º 6
0
    def findSafeRegion(self, pose):
        pose = np.asarray(pose)
        tformForProjection = transformUtils.frameFromPositionAndRPY(
            [0, 0, 0], pose[3:] * 180 / np.pi)
        tform = transformUtils.frameFromPositionAndRPY(pose[:3],
                                                       pose[3:] * 180 / np.pi)

        contact_pts_on_plane = np.zeros((2, self.bot_pts.shape[1]))
        for j in range(self.bot_pts.shape[1]):
            contact_pts_on_plane[:, j] = tformForProjection.TransformPoint(
                [self.bot_pts[0, j], self.bot_pts[1, j], 0])[:2]

        Rdot = np.array([[0, -1], [1, 0]])
        contact_vel_in_world = Rdot.dot(contact_pts_on_plane)

        c_region = {'A': [], 'b': []}

        for i in range(self.planar_polyhedron.A.shape[0]):
            ai = self.planar_polyhedron.A[i, :]
            n = np.linalg.norm(ai)
            ai = ai / n
            bi = self.planar_polyhedron.b[i] / n

            p = ai.dot(contact_pts_on_plane)
            v = ai.dot(contact_vel_in_world)

            mask = np.logical_or(p >= 0, v >= 0)
            for j, tf in enumerate(mask):
                if tf:
                    c_region['A'].append(np.hstack((ai, v[j])))
                    c_region['b'].append([bi - p[j]])

        A = np.vstack(c_region['A'])
        b = np.hstack(c_region['b'])

        b = b + A.dot(np.array([0, 0, pose[5]]))

        self.c_space_polyhedron = Hrep(A, b)
        return SafeTerrainRegion(A, b, [], [], tform)
Ejemplo n.º 7
0
def mkhull(points):
    p = Vrep(points)
    return Hrep(p.A, p.b)
Ejemplo n.º 8
0
def calc_pd_c(file):
    A, b, elements, sec_phases, mu_dep, dep_elem = read_cplap_input(file)
    p = Hrep(A, b)
    return p
def robust_id(config, node):
    """
    Robust identification by solving dual
    inputs: config file name, node number.
    it is assumed that all subnodes have functions
    """
    node_params = read_config.parse_node_config(config, node)
    node_params['criteria_functions'] = {
    }  # subnode functions called "criteria functions" for passing to capacity_parameters methods
    node_params['criteria_fgrad'] = {
    }  # subnode gradients called "criteria fgrad" for passing to capacity_parameters methods
    node_params['limits'] = {
    }  # subnode limits for constructing AZ, bZ, AeqZ, beqZ
    for subnode in node_params['subnodes']:
        try:
            node_params['criteria_functions'][
                subnode] = read_config.parse_node_config(config,
                                                         subnode)['function']
        except:
            print "Not all subnodes have functions! ", subnode
            sys.exit(1)
        try:
            node_params['criteria_fgrad'][
                subnode] = read_config.parse_node_config(config,
                                                         subnode)['fgrad']
        except:
            print "Not all subnodes have gradients! ", subnode
            sys.exit(1)
        try:
            node_params['limits'][subnode] = read_config.parse_node_config(
                config, subnode)['limits']
        except:
            print "Not all subnodes have limits! ", subnode
            sys.exit(1)
    node_params = read_config.relabel(
        node_params
    )  # relabel DM information to 1,2,... so that it can be passed to capacity_parameters methods
    A, b = capacity_parameters.gen_inequalities(node_params, convex=0)
    Aeq, beq = capacity_parameters.gen_equalities(node_params, k_additive=2)
    # Convert A,b,Aeq,beq to Ax<=b form, reduce to 2add and calculate vertices
    #
    A = matrix(cvx.matrix([A, Aeq, -Aeq]))
    b = matrix(cvx.matrix([b, beq, -beq]))
    # A = matrix(cvx.matrix([A]))
    # b = matrix(cvx.matrix([b,beq,-beq]))
    # Convert to 2-additive for vertex search simplification
    #
    A, b, bas = convert2kadd(A, b)
    # bas.insert(0,0)
    p = Hrep(A, b)
    Vm = array(p.generators)
    # print Vm
    # print shape(Vm)
    Vm = convertnadd(Vm, bas)
    # print Vm
    # print shape(Vm)
    cap_list = []
    Z = sum(node_params['limits'].values())
    print Z
    for Zi in linspace(0, Z, 10):
        print "############################################"
        print "BUDGET VALUE", Zi
        print "############################################"
        node_params['limits']['total'] = Zi
        # print gen_constraints(node_params)
        cap_list.append((Zi, nc_dual(Vm, node_params)))
    print cap_list