A method to improve a lithographic process of imaging a portion of a design layout onto a substrate using a lithographic projection apparatus, the method including: computing a multi-variable cost function, the multi-variable cost function being a function of a stochastic variation of a characteristic of an aerial image or a resist image, or a function of a variable that is a function of the stochastic variation or that affects the stochastic variation, the stochastic variation being a function of a plurality of design variables that represent characteristics of the lithographic process; and reconfiguring one or more of the characteristics of the lithographic process by adjusting one or more of the design variables until a certain termination condition is satisfied.