iterative determination of states and training