Flexible combined heat and power plant