Cvx_optval following a pattern

Hi everyone,

So, I am using a linearized version of a non-linear cost. I run the optimization until the difference between two consecutive cvx_optval reduces below a threshold. For every new optimization, the solution of previous optimization is used as the linearization points. However, the difference never reaches below the threshold (and threshold is not too high or too low). On debugging I observed that the cvx_optval follows a pattern in my program ie cvx_optval over 10 runs is
1.0e+03 *
Columns 1 through 10

-0.0172 -3.4586 -2.9413 -3.4586 -2.9413 -3.4586 -2.9413 -3.4586 -2.9413 -3.4586

What might be the isssue?
Thanks in advance!

You need to provide more information for anyone to help you beyond the general statement below… Preferably a reproducible problem

Anyhow, your iterative algorithm may not necessarily converge at all, let alone to a local optimum of your original nonlinear problem. In your case, it appears that the algorithm may never converge.In general, some type of control on step size, such as line search or trust region, might be necessary to guarantee convergence to a stationary point. Your algorithm evidently omits such control, hence may not converge to anything. It is easy to be seduced when you see only examples where a heuristic algorithm converges to a correct answer, and don’t see examples where it doesn’t.

Okay, so here is the linearized cost function
cost = (xl(n) - robo_px(n))^2 + (yl(n) - robo_py(n))^2 + 2*(xl(n) - robo_px(n))(Px(n) - xl(n)) + 2(yl(n) - robo_py(n))*(Py(n) - yl(n));
where xl,yl are the linearization points, Px,Py are the optimization variable and robo_px, robo_py are the initial parameters provided as input to the optimization algo.
I minimize the cost given constraints on the optimization variables. Before iterating over the optimization routine the linearization points are updates as
xl = Px;
yl = Py;
Also if the difference between consecutive cvx_optval is not below a threshold the optimization over same horizon set is repeated but with updated linearization points.
if (optvalt(i) - optval(i-1) > 0.1) || (optval(i) - optval(i-1) < -0.1)
accept the solution
else
repeat
end

You haven’t provided a reproducible problem, but I would say the assessment in my previous post stands.

Try reading https://www.amazon.com/Numerical-Optimization-Operations-Financial-Engineering/dp/0387303030 to get an appreciation for what it takes to have any assurance that an iterative (linearization) algorithm for a nonlinear optimization problem will converge.

It would be appreciated If you can brief what you specifically mean by reproducible problem. Should I post the entire code?

The entire code, complete with all input data. I.e, so someone can copy and paste into a new MATLAB session and run the same problem as you did.

You can find the required files here [https://drive.google.com/open?id=1s1cH4963bvpXIr-dq0QevktIHD4yK5Hb]
Order of call: main->lin_footprint_call_mpc
You may find the optimization routine to be immature since I have just started!
Thanks in advance.

As a matter of safety and protocol, everything, including inputs, needs to be provided on this forum, not on google drive. Anyhow, I suggest you do some reading along the lines I suggested.

helping you debug or analyze a heuristic algorithm built on top of CVX is really outside the scope of this forum though. I.e., if your heuristic algorithm doesn’t converge, that’s your problem to deal with, and it is a “bonus” if any readers choose to provide such help.

I suggest that given your immaturity in the filed, you may be better off using an off-the-shelf nonlinear optimization code to solve your problem, rather than trying to write your own algorithm. I’m not clear on what specific problem type your problem is, so can not recommend any particular code.