In this paper, we consider a general class of discrete-time optimal control problems subject to all-time-step constraints on the state and variables. The derivations gradient formulas for cost constraint functions constrained problem are rather involved. We present simple approach these based reversed automatic differentiation. On basis, numerical algorithm is developed solve problem. then cont...