Methods for optimized design and management of CHP systems for district heating networks (DHN)