For the particular polynomial, you don't need any fancy techniques, as opaquely pointed out by @Noah Stein: you write $J=\-sum_{i=0}^n y_{i-1}y_i y_{i+1} + \sum_{i=0}^n y_{i-1}y_{i+1}.$ Both the first and the second sums depend fairly simply on the pattern of runs of $1$s and $0$s in your sequence $y_0, \dotsc, y_n$ -- I leave it to you to work out the details, which are not too hard. In general, you are trying to maximize a sum of boolean monomials, and that is both a hard and and often-arising problem. One relaxation is to replace your variables $y_i$ by $z_i^\alpha,$ where $z_i$ are continuous in [0, 1], and $\alpha$ is a positive real number. As $\alpha$ goes to infinity, the problem becomes discrete, and one can try simulated annealing to deal with the continuous problem -- there are no general techniques, since the function is generally not convex, so you have to slaughter many goats and hope for the best (nonetheless, I am ashamed to admit that many centuries ago I was one of the inventors on a patent based on the above idea for the purpose of VLSI testing).