A method for the optimal design of water distribution networks is presented. It defines the least-cost solution for a closed network, using standard diameters on the market. It can take into account the branches whose diameter value are assigned (existing); the range of velocities in the pipes and of the hydraulic heads can be imposed. And, lastly, the desired solution is obtained with acceptable computer time. The basic hydraulic laws and the other constraints are introduced into the objective function to be minimized. Thus, all constraint equations are eliminated, and the problem is to determine the minimum function (even if complex). The solution is found using an iterative method which considers that the most economical distribution system is always an open network. The method has been applied to a complex network (many loops), and has introduced acceptable computer times.