Пример #1
0
                       [3, 6]]

    cp.facets = [[0, 3, 2],
                 [1, 2, 3],
                 [1, 3, 4],
                 [1, 4, 5],
                 [0, 3, 6]]

    cp.cnstr_lhs = [[(0, 0, 1.0)],
                    [(0, 1, 1.0)],
                    [(0, 2, 1.0)],
#                    [(1, 1, 1.0)],
#                    [(1, 2, 1.0)],
                     ]

    cp.cnstr_rhs = [0.0, 0.0, 0.0, ]# 0, 0, 0, ]

    cp.tf_lst = [(caf, [1, 2, 3, 4, 5, 6])]

    x0 = np.zeros((cp.n_dofs), dtype = float)

    print 'initial lengths\n', cp.c_lengths
    print 'initial vectors\n', cp.c_vectors
    print 'initial G\n', cp.get_G(x0)
    print 'initial G_du\n', cp.get_G_du(x0)

    cp.solve(x0)

    # Visualization
    cpv = CreasePatternView(data = cp, show_cnstr = True)
    cp.nodes = [[ 0, 0, 0 ],
                [ 1, 1, 0 ],
                [ 0, 2, 0 ]]

    cp.crease_lines = [[ 0, 1 ],
                       [ 1, 2 ]]

    cp.cnstr_lhs = [[(0, 0, 1.0)],
                    [(0, 1, 1.0)],
                    [(0, 2, 1.0)],
                    [(2, 0, 1.0)],
                    [(2, 1, 1.0)],
                    [(2, 2, 1.0)], ]

    cp.cnstr_rhs = [0.0, 0.0, 0.0, 0, 0, 0]

    x0 = np.zeros((cp.n_dofs), dtype = float)

    print 'initial lengths\n', cp.c_lengths
    print 'initial vectors\n', cp.c_vectors
    print 'initial G\n', cp.get_G(x0)
    print 'initial G_du\n', cp.get_G_du(x0)

    def f(x):
        x = x.reshape(cp.n_n, cp.n_d)
        X = cp.get_new_nodes(x)
        caf.X_arr = [X[1]]
        dist2 = np.linalg.norm(caf.d_arr)
        return dist2