Enabling smart control by optimally managing the State of Charge of district heating networks