Rlearning added and the cost function is changed to just q_k