Constrained optimization with changing constraints based on value of target function

Is this possible, that some constraints have parameters that depend on the target function? Or do the constraints need to be statable in an unchanging way?

Do you mean something like this?:

NMinimize[{f, x^2 + y^2 + f^2 <= 4} /. f -> Cos[x] + Cos[y], {x, y}]
(*  {0.356557, {x -> 1.39121, y -> -1.39191}}  *)

Almost, but not quite. The constraints need to be defined outside NMinimize, as they are a bit complicated. See new file. It works now! Thanks.

Wait, I need to add stuff that was in the original file, that I simplified… Hang on. It works now.