discrete dynamic programming module from R to C++