  In this work we study the variational problem associated to dimer models, a
class of models from integrable probability and statistical mechanics in
dimension two which have been the focus of intense research efforts over the
last decades. These models give rise to an infinite family of
non-differentiable functionals on Lipschitz functions with gradient constraint,
determined by solutions of the Dirichlet problem on compact convex polygons for
a class of Monge-Amp\`ere equations. We settle a number or outstanding open
questions for this infinite class functionals. In particular we prove a
complete classification of the regularity of minimizers, also known as height
functions, for all dimer models for a natural class of polygonal (simply or
multiply connected) domains much studied in numerical simulations and
elsewhere. Our classification in particular implies that the Pokrovsky-Talapov
law holds for all dimer models at a generic point on the frozen boundary and in
addition shows a very strong local rigidity of dimer models which can be
interpreted as a geometric universality result. Furthermore, we give a complete
classification of the regularity of the associated free boundary, also known in
the literature as frozen boundary or arctic curves and prove that they are all
algebraic curves. The lack of differentiability of the functionals is
intimately connected to the boundary behaviour of the solutions to the
Monge-Amp\`ere equations and we prove a complete classification for these, of
independent interest.
