Real-time Optimization of the Battery Banks Lifetime in Hybrid Residential Electrical Systems