In this study we first review existing source optimization methods. Lack of rigorous formulations motivates discussion of the optimization objectives and constraints. We stress the importance of using weighted and so-called Sobolev norms. Second, we state the main optimization problem as a set of the optimization objectives in a form of functional norm integrals to maximize image fidelity and source smoothness. We reduce this to a non-negative least square (NNLS) problem, which is solved by standard numerical methods. Third, we analyze solutions for important practical cases: alternating phase shifting applied to regular and semiregular pattern of contact holes, two types of SRAM cells with design rules from 130 to 250 nm, and a complex semidense contact layer pattern. Finally, we show how constraint optimization can be used to smooth strong off-axis quadrupole illuminations to achieve better image fidelity for some selected layout patterns.