Nonlinear optimization of district heating networks