Optimal control of ODE systems involving a rate independent variational inequality