Optimization of the battery size for PV systems under regulatory rules using a Markov-Chains approach