# 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?

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!