Battery system grouping optimization