Charge optimization of lithium-ion batteries for electric-vehicle application