Combined optimization of electrical and thermal energy storage system operations