Finite dynamic programming