aima/mdp.py
def policy_evaluation(pi, U, mdp, k=20):
    """Return an updated utility mapping U from each state in the MDP to its
    utility, using an approximation (modified policy iteration)."""
    R, T, gamma = mdp.R, mdp.T, mdp.gamma
    for i in range(k):
        for s in mdp.states:
            U[s] = R(s) + gamma * sum([p * U[s1] for (p, s1) in T(s, pi[s])])
    return U
def policy_evaluation(pi, U, mdp, k=20):
    """Return an updated utility mapping U from each state in the MDP to its
    utility, using an approximation (modified policy iteration)."""
    R, T, gamma = mdp.R, mdp.T, mdp.gamma
    for i in range(k):
        for s in mdp.states:
            U[s] = R(s) + gamma * sum([p * U[s1] for (p, s1) in T(s, pi[s])])
    return U
def policy_evaluation ( pi , U , mdp , k = 20 ) : R , T , gamma = mdp . R , mdp . T , mdp . gamma for i in range ( k ) : for s in mdp . states : U [ s ] = R ( s ) + gamma * sum ( [ p * U [ s1 ] for ( p , s1 ) in T ( s , pi [ s ] ) ] ) return U
Return an updated utility mapping U from each state in the MDP to its
    utility, using an approximation (modified policy iteration).
Return an updated utility mapping U from each state in the MDP to its utility using an approximation ( modified policy iteration ) .