Dynamic Programming Optimization CMEX Routine