How to reduce the time to setup the optimization problem?

Hi,

I am using cvx to solve convex optimization for predictive control. I put all the constraints and objective function in the script block:

cvx_begin
… …
… …
cvx_end

, in which I declare the decision variables and define constraints and objective function. Since feedback control is real time task, I want to solve this problem fast. I calculate the computation time by ‘tic’ and ‘toc’ functions, which placed before ‘cvx_begin’ and after ‘cvx_end’, respectively. It takes around 16 seconds. However, cvx solver outputs the following information:

''Total CPU time (secs) = 0.94
CPU time per iteration = 0.04 ‘’.

I wonder is the ‘0.94 second’ the time used to solve the problem, while 16 seconds is the time to setup and solve it? If so, is it possible to program in a form that the time is less.

Any advice are welcome. Thanks a lot for your time in advance.

Sincerely
Yang

I’m afraid that CVX is not designed for speed, but convenience. If you need speed, especially for smaller models or models that require lots of FOR loops to build, you will simply have to build it outside of CVX.

Thanks for your suggestion, mcg. Could you please give more hints if the objective function and constraints are nonlinear? For quadratic programming, I know how to get the H, F, A, b… matrix and pass it to CVX directly. But for nonlinear ones, I don’t know. Thanks a lot.

I’m afraid not, no. I’m available for consulting projects, but I can’t really offer general advice on how to go about this.

thanks !!!