Model for optimal malfunction management in extended district heating networks