A PDE-constrained optimization formulation for discrete fracture network flows