This paper derives from a research project investigating the systematic use of formal optimization techniquesin computer aided building design. A comprehensive modelof drainage design suitablefor optimization is developed. After limited success with a very powerful general purpose optimizationprogram based upon the Geometric Programming technique, a problem dependent algorithm is developed based upon Dynamic Programming. The latter technique is shown in actual designs to produce optimal drainage designs simply and cheaply.