Generalised problem function.