예제 #1
0
def td_solution(P, G, L, X, r):
    D = mdputils.distribution_matrix(P)
    A = mult(X.T, D, resolvent(P, G), X)
    A_inv = np.linalg.pinv(A)
    b = mult(X.T, D, r)
    return np.array(np.dot(A_inv, b))
예제 #2
0
def td_solution(P, G, L, X, r):
    D = mdputils.distribution_matrix(P)
    A = mult(X.T, D, resolvent(P, G), X)
    A_inv = np.linalg.pinv(A)
    b = mult(X.T, D, r)
    return np.array(np.dot(A_inv, b))
예제 #3
0
def least_squares(P, G, X, r):
    """Compute the optimal weights via least squares."""
    v = bellman(P, G, r)
    D = mdputils.distribution_matrix(P)
    return np.array(mult(np.linalg.pinv(mult(X.T, D, X)), X.T, D, v))
예제 #4
0
def least_squares(P, G, X, r):
    """Compute the optimal weights via least squares.""" 
    v = bellman(P, G, r)
    D = mdputils.distribution_matrix(P)
    return np.array(mult(np.linalg.pinv(mult(X.T, D, X)), X.T, D, v))