This study is an extended and comprehensive analysis to accomplish optimal sizing for a biological nutrient removal (BNR) system with an A2O BNR activated sludge process using activated sludge models (ASM) kinetic models. A highly nonlinear activated sludge model combined with the EAWAG Bio-P module is formulated and optimized using a generalized reduced gradient solver. Primary and final clarifications are included with the A2O biotreatment scheme along with oxygen-supplying units. This paper includes a detailed description of model formulation, problem definition and discussion of optimal design in terms of capital (CAPEX) and operating (OPEX) cost estimates. The optimization problem is formulated and solved using typical cost factors and operating/design constraints applied to a typical illustrative system treating medium-strength wastewater. Results indicated that maintenance and sludge disposal expenditures represent more than 50% of the total annual cost and 80% of the annual running operating cost. Another major finding was that a primary clarifier is found to be cost ineffective in the A2O BNR process. Sensitivity of the optimal solutions and model performance to varying inflow conditions and to other effluent limits and model parameters will be discussed in another paper.