A concept from optimization theory, specifically, mathematical programming, is proposed for designing drugs with desired properties. The mathematical programming formulation is solved to obtain the optimal descriptor values, which are employed in the Cerius2 modeling environment to infer the optimal lead candidates, in the sense that they exhibit both high selectivity and activity while ensuring low toxicity. It has been observed that unique substituent groups and their molecular conformations are responsible for attaining the goal of simultaneous high selectivity and activity. Both linear and nonlinear quantitative structure activity relationships (QSARs) have been developed for use in the proposed approach. A comparative study of these models is done, and it is shown that the QSARs are well represented by nonlinear models. The proposed mathematical programming strategy has been demonstrated for a class of nonclassical antifolates for Pneumocistiscariniiand Toxoplasma gondii dihydofolate reductase. Some of the potential leads found in this study have biological properties similar to those in the open literature. We believe the technique proposed is general and can be applied to other structure based drug design.