Trade-off between end of life of battery and reliability in a photovoltaic system