Some embodiments of the invention provide a method of specifying a cost function
that represents the estimated distance between an external state and a set of states
in a multi-state space that represents a region of a design layout. The method
identifies a polygon that encloses the set of states. It then identifies vectors
to project from the vertices of the polygon. Based on the projected vectors, the
method identifies a set of distances that includes the distance between the polygon
and each point in a set of points in the external state. The method then uses the
identified set of distance to specify the cost function.