Fixed bug on time-series optimization