Estadísticas de Water duct with intermediate taking. Application of the theory of optimization and generalization of the problem