A way to deal with nonlinear boundary conditions in open-channel optimal control problems