DynamicNumericDiffCostFunction--the solution