C++ implementation of astateful Dynamic Programming framework