Optimal Iterative Learning Control for Batch Processes in the Presence of Time-Varying Dynamics