1. A computer-implemented method for determining a mask pattern to be used on a photo-mask in a photolithographic process, wherein the photo-mask has a plurality of distinct types of regions having distinct optical properties, comprising: partitioning a target pattern into subsets of the target pattern; distributing the subsets of the target pattern to a plurality of processors; and determining a set of second mask patterns each of which corresponding to one of the subsets of the target pattern, wherein at least one of the second set of mask patterns is determined by performing operations including: providing a first mask pattern that includes a plurality of distinct types of regions corresponding to the distinct types of regions of the photo-mask; calculating, by a computer, a gradient of a function, wherein the function depends on the first mask pattern and an estimate of a wafer pattern that results from the photolithographic process utilizing at least a portion of the first mask pattern, and wherein the gradient is calculated in accordance with a formula obtained by taking a derivative of the function; and determining a second mask pattern based, at least in part, on the gradient.