def agent2(conn3, max_iter, A2, b2):
    coef_vect = deepcopy(b2)
    for i in range(max_iter):
        lamb = conn3.recv()
        coef_vect[0] = b2[0] - lamb
        v1 = gauss(np.concatenate((A2, coef_vect), axis=1))
        conn3.send(v1)
def agent1(conn1, max_iter, A1, b1):
    coef_vect = deepcopy(b1)
    for i in range(max_iter):
        lamb = conn1.recv()
        coef_vect[-1] = b1[-1] + lamb
        v1 = gauss(np.concatenate((A1, coef_vect), axis=1))
        conn1.send(v1)
Exemplo n.º 3
0
def agent1(conn1, send_vec1, max_iter, A1, b1, xi_word_limit):
    coef_vect = deepcopy(b1)
    for i in range(max_iter):
        lamb_bin = conn1.recv()
        lamb_float = bin2float(lamb_bin)
        coef_vect[-1] = b1[-1] + lamb_float
        v1 = gauss(np.concatenate((A1, coef_vect), axis=1))
        # Simulate word limit on message send by Agent 2
        conn1.send(float2bin(v1[-1], xi_word_limit))
        send_vec1.send(v1)
Exemplo n.º 4
0
def agent2(conn3, send_vec2, max_iter, A2, b2, xi_word_limit):
    coef_vect = deepcopy(b2)
    for i in range(max_iter):
        lamb_bin = conn3.recv()
        lamb_float = bin2float(lamb_bin)
        coef_vect[0] = b2[0] - lamb_float
        v2 = gauss(np.concatenate((A2, coef_vect), axis=1))
        # Simulate word limit on message send by Agent 2
        conn3.send(float2bin(v2[0], xi_word_limit))
        send_vec2.send(v2)
def do_check(A1, A2, b1, b2, verbose=False):
    A = augment_matrices(A1, A2)
    b = augment_vect(b1, b2)

    begin = time.time()
    v = gauss(np.concatenate((A, b), axis=1))
    end = time.time()

    if verbose:
        print("No decomposition takes %fs." % (end - begin))

    return v[len(b1) - 1], end - begin
def agent1(lamb, A1, b1):
    coef_vect = deepcopy(b1)
    coef_vect[-1] = b1[-1] + lamb
    v1 = gauss(np.concatenate((A1, coef_vect), axis=1))
    return v1[-1]
def agent2(lamb, A2, b2):
    coef_vect = deepcopy(b2)
    coef_vect[0] = b2[0] - lamb
    v2 = gauss(np.concatenate((A2, coef_vect), axis=1))
    return v2[0]