Optimization of the thermal profiles of buildings connected with a large district heating network