Optimization of Ramified Flow Networks