  Valued constraint satisfaction problems (VCSPs) are a large class of
computational optimisation problems. If the variables of a VCSP take values
from a finite domain, then recent results in constraint satisfaction imply that
the problem is in P or NP-complete, depending on the set of admitted cost
functions. Here we study the larger class of cost functions over countably
infinite domains that have an oligomorphic automorphism group. We present a
hardness condition based on a generalisation of pp-constructability as known
for (classical) CSPs. We also provide a universal-algebraic polynomial-time
tractability condition, based on the concept of fractional polymorphisms.
  We apply our general theory to study the computational complexity of
resilience problems in database theory (under bag semantics). We show how to
construct, for every fixed conjunctive query (and more generally for every
union of conjunctive queries), a set of cost functions with an oligomorphic
automorphism group such that the resulting VCSP is polynomial-time equivalent
to the resilience problem; we only require that the query is connected and show
that this assumption can be made without loss of generality. For the case where
the query is acylic, we obtain a complexity dichotomy of the resilience
problem, based on the dichotomy for finite-domain VCSPs. To illustrate the
utility of our methods, we exemplarily settle the complexity of a (non-acyclic)
conjunctive query whose computational complexity remained open in the
literature by verifying that it satisfies our tractability condition. We
conjecture that for resilience problems, our hardness and tractability
conditions match, which would establish a complexity dichotomy for resilience
problems for (unions of) conjunctive queries.
