  We formulate and prove a variational principle (in the sense of
thermodynamics) for random domino tilings, or equivalently for the dimer model
on a square grid. This principle states that a typical tiling of an arbitrary
finite region can be described by a function that maximizes an entropy
integral. We associate an entropy to every sort of local behavior domino
tilings can exhibit, and prove that almost all tilings lie within epsilon (for
an appropriate metric) of the unique entropy-maximizing solution. This gives a
solution to the dimer problem with fully general boundary conditions, thereby
resolving an issue first raised by Kasteleyn. Our methods also apply to dimer
models on other grids and their associated tiling models, such as tilings of
the plane by three orientations of unit lozenges.
