A flexible Markov-chain model for simulating demand side management strategies with applications to distributed photovoltaics