  We introduce a problem class we call Polynomial Constraint Satisfaction
Problems, or PCSP. Where the usual CSPs from computer science and optimization
have real-valued score functions, and partition functions from physics have
monomials, PCSP has scores that are arbitrary multivariate formal polynomials,
or indeed take values in an arbitrary ring.
  Although PCSP is much more general than CSP, remarkably, all (exact,
exponential-time) algorithms we know of for 2-CSP (where each score depends on
at most 2 variables) extend to 2-PCSP, at the expense of just a polynomial
factor in running time. Specifically, we extend the reduction-based algorithm
of Scott and Sorkin; the specialization of that approach to sparse random
instances, where the algorithm runs in polynomial expected time;
dynamic-programming algorithms based on tree decompositions; and the
split-and-list matrix-multiplication algorithm of Williams.
  This gives the first polynomial-space exact algorithm more efficient than
exhaustive enumeration for the well-studied problems of finding a minimum
bisection of a graph, and calculating the partition function of an Ising model,
and the most efficient algorithm known for certain instances of Maximum
Independent Set. Furthermore, PCSP solves both optimization and counting
versions of a wide range of problems, including all CSPs, and thus enables
samplers including uniform sampling of optimal solutions and Gibbs sampling of
all solutions.
