The value is cycling in the two value

I am guessing you have implemented a higher level algorithm which solves a sequence of convex CVX optiimzation problems, feeding the result from one iteration of your algorithm into the input of the next. Perhaps Sequential Convex Programming, or alternating variables.

The good news is that when someone like Stephen Boyd applies such an algorithm to problems he shows in a book, paper, or class notes, it usually works well. The bad news is when an ordinary Joe applies such an algorithm they’ve implemented themself to their own problem, it often doesn’t converge at all (cycling is but one of many possibilities), and when it does converge, it may not be to a local optimum, let alone global optimum, of the original problem. Starting value, which is input to your high level algorithm, may have a significant effect on whether the overall algorithm converges at all, and if it does converge, what it converges to.

My advice: You are usuaully better off using a high quality nonlinear non-convex optimization solver, which implements line search, trust region, or other safegaurd, than to use you own unsophisticated, unsafeguarded, “poor man’s” non-convex nonlinear optimization solver. There’s a reason those solvers are more than 10 lines long.