Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. # Variables Declaration
  2. cu = C[:,0:1]
  3. cd = C[:,1:2]
  4. cl = C[:,2:3]
  5. cr = C[:,3:4]
  6. gamma = 0.99
  7.  
  8. # Matrix creation
  9. J = np.zeros((6,1))
  10.  
  11. # Initialize variables
  12. err = 1
  13. i = 0
  14.  
  15. while err > 1e-8:
  16. Qu = cu + gamma * U.dot(J)
  17. Qd = cd + gamma * D.dot(J)
  18. Ql = cl + gamma * L.dot(J)
  19. Qr = cr + gamma * R.dot(J)
  20. Jnew = np.min((Qu, Qd, Ql, Qr), axis=0)
  21. err = np.linalg.norm(Jnew - J)
  22. i+=1
  23. J = Jnew
  24.  
  25. print(J)
  26. print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement