The method of virtual stations, introduced in Birgin and Martínez (Optim. Eng. 26, 965–1010, 2025), deals with the prediction of river levels by means of polynomial regression models using only elevation data and inflow forecasts. The reliable computation of virtual stations requires specific optimization methods. The objective error function is nonsmooth and not defined at points that could, in principle, be visited by standard minimization algorithms. To tackle this situation, a modified form of the Augmented Lagrangian is introduced. Discontinuities of the derivatives are handled by means of approximate minimizations on a sequence of boxes in which the objective function is smooth. Numerical experiments demonstrate the effectiveness of the introduced techniques for river-flow predictions.