Maximum number of iterations exceeded

829 views
Skip to first unread message

Eric

unread,
Mar 26, 2014, 4:20:20 AM3/26/14
to yal...@googlegroups.com


Could you help me solve this problem:

Thank you so much.

I use a very simple example from a paper to see the effects of short and long horizons respectively (fixed horizon).

If I use the following solver, and set N=2, everything goes well.

solvesdp(constraints,objective,sdpsettings('verbose',1,'solver','quadprog'));


If I set N=10, get display:

Maximum number of iterations exceeded; increase options.MaxIter.
To continue solving the problem with the current solution as the
starting point, set x0 = x before calling quadprog.


and then I use
solvesdp(constraints,objective,sdpsettings('verbose',1,'solver','quadprog','quadprog.maxiter',5000));

Still get display:
Maximum number of iterations exceeded; increase options.MaxIter.
To continue solving the problem with the current solution as the
starting point, set x0 = x before calling quadprog.





on the other hand, when I use

solvesdp(constraints,objective,sdpsettings('verbose',1,'solver','qpoases'));

no error is shown, but all the states and control are NaN.

Do you have any suggestion?

Thank you again.
 
Message has been deleted

Johan Löfberg

unread,
Mar 26, 2014, 4:24:15 AM3/26/14
to yal...@googlegroups.com
quadprog is a pretty crappy solver, so no surprise there

When you used qpoases, you must have seen some error code or something (what is displayed when you run solvesdp, and what error code in returned in the output from solvesdp?)

Install a quality QP solver, such as cplex, gurobi, mosek (all with free licenses if you are in academia)

Johan Löfberg

unread,
Mar 26, 2014, 4:34:41 AM3/26/14
to yal...@googlegroups.com
FYI, you can simulate MPC much faster in YALMIP by using precompiled optimizer objects

CON = [];
OBJ
= 0;
for j = 1:N
    CON
= [CON, x{j+1} == A*x{j} + B*u{j}];
    OBJ
= OBJ + x{j}'*Q*x{j} + u{j}*R*u{j};
    CON = [CON,  abs(u{j}) <= 2];
end
OBJ = OBJ + x{1+N}'
*P*x{1+N};
controller
= optimizer(CON,OBJ,sdpsettings('solver','quadprog'),x{1},u{1});
x_sim
(:,1) = [1;1];
for k = 1:40
   
[u_sim(:,k),problem] = controller{x_sim(:,k)};
   
if problem
        disp
('Bugger!');
   
end
    x_sim
(:,k+1) = A*x_sim(:,k) + B*u_sim(:,k);
end

http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Examples.StandardMPC
http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Commands.Optimizer

Of course, preferably using some other solver than quadprog

Eric

unread,
Mar 26, 2014, 6:29:27 AM3/26/14
to yal...@googlegroups.com
Hi Johan, 

Thank you pretty much. You help me a lot.

For your precompiled optimiser, I saw this example before. 
Here I have another question. 
if A, B, and/or C are functions of time step k, can we still use this form ? 


Johan Löfberg

unread,
Mar 26, 2014, 6:53:14 AM3/26/14
to yal...@googlegroups.com
Yes
http://users.isy.liu.se/johanl/yalmip/pmwiki.php?n=Blog.Beta-version-of-a-more-general-optimizer

You simply have to declare have A as an sdpvar (or different A along the whole trajectory) and then define it/them as parametric variables, as you do with x{1} now. notice that you now must use the +solver directive when specifying solver.

Eric

unread,
Mar 26, 2014, 7:17:56 AM3/26/14
to yal...@googlegroups.com
OK, I get it. Many thanks, Johan. 

I use the solver 'qpoases' to run the following program. Why is nothing displayed in the output, and all the states and inputs are NaN.   If appropriate, you may run this code below


yalmip('clear')
clear all;

A = [0.7326 -0.0861;0.1722 0.9909];
B = [0.0609;0.0064];
C = [0 1.4142];

Q = eye(2);
R = 0.01;
P = dlyap(A,Q); % dlyap is used to solve P = A'*P*A + Q
                % P = [3.0485   -2.5055
                %      -2.5055   12.9916];

nx = 2;
nu = 1;
N = 2;
u = sdpvar(repmat(nu,1,N),repmat(1,1,N));
x = sdpvar(repmat(nx,1,N+1),repmat(1,1,N+1));
x_sim(:,1) = [1;1];

for k = 1:20
    CON = [];
    OBJ = 0;
    
    x{1} = x_sim(:,k);
    
    for j = 1:N        
        x{j+1} = A*x{j} + B*u{j};
        OBJ = OBJ + x{j}'*Q*x{j} + u{j}*R*u{j};
        CON = [CON,  abs(u{j}) <= 2];
    end
    OBJ = OBJ + x{1+N}'*P*x{1+N};
    
    solvesdp(CON,OBJ,sdpsettings('verbose',2,'solver','qpoases'));
    u_sim(:,k) = double(u{1}); 
    x_sim(:,k+1) = A*x_sim(:,k) + B*u_sim(:,k); 
    
end

    figure; 
    subplot(3,1,1);
    plot(x_sim(1,:)); 
    xlabel('k');
    ylabel('x1');
    subplot(3,1,2);
    plot(x_sim(2,:));
    xlabel('k');
    ylabel('x2');
    subplot(3,1,3);
    stairs(1:length(u_sim),u_sim,'r');
    xlabel('k');
    ylabel('u');

Johan Löfberg

unread,
Mar 26, 2014, 7:39:43 AM3/26/14
to yal...@googlegroups.com
Once again: What does solvesdp actually return. Remove the ; and show what is displayed

Eric

unread,
Mar 26, 2014, 8:08:55 AM3/26/14
to yal...@googlegroups.com
>> mpc_simple

ans = 

    yalmiptime: NaN
    solvertime: NaN
          info: [1x241 char]
       problem: 9

>> help qpoases
 qpOASES -- An Implementation of the Online Active Set Strategy.
 Copyright (C) 2007-2014 by Hans Joachim Ferreau, Andreas Potschka,
 Christian Kirches et al. All rights reserved.
 
 qpOASES is distributed under the terms of the

Johan Löfberg

unread,
Mar 26, 2014, 8:17:01 AM3/26/14
to yal...@googlegroups.com
so qpoases has crashed, or the call to qpoases has crashed (error code 9, see text in info)

Turn on the option 'debug' in sdpsettings to see the crash in detail

Eric

unread,
Mar 26, 2014, 8:29:35 AM3/26/14
to yal...@googlegroups.com
>> mpc_simple
Cannot find an exact (case-sensitive) match for 'qpoases'

The closest match is: qpOASES
in C:\Users\cezou\Documents\MATLAB\qpOASES-3.0beta\interfaces\matlab\qpOASES.mexw64


Error in callqpoases>callsolver (line 71)
[x,fval,exitflag,iter,lambda] = qpoases(model.Q, model.c, A,
model.lb,model.ub,lbA,ubA,[],options.qpoases);

Error in callqpoases (line 15)
solution = callsolver(model,options);

Error in solvesdp (line 355)
    eval(['output = ' solver.call '(interfacedata);']);

Error in mpc_simple (line 37)
      solvesdp(CON,OBJ,sdpsettings('debug',1,'verbose',2,'solver','qpOASES'))

Johan Löfberg

unread,
Mar 26, 2014, 8:39:12 AM3/26/14
to yal...@googlegroups.com
OK, so obviously qpOASES.mexw64 has to be renamed, or the call in callqpoases has to be changed if you want to use that solver

I guess I haven't used qpoases since MATLAB got more stringent about case sensitivity

Eric

unread,
Mar 26, 2014, 9:29:02 AM3/26/14
to yal...@googlegroups.com

Hi Johan, I changed all the 'qpOASES' to 'qpoases' including the filename and content in the files. 
But it does no solve the problem. 
Do you have any other suggestions? otherwise i have to choose the solvers as you recommended -- cplex, gurobi, mosek

Johan Löfberg

unread,
Mar 26, 2014, 9:31:40 AM3/26/14
to yal...@googlegroups.com
So has MATLAB really recognized this? What is returned if you write

which qpoases -all


Eric

unread,
Mar 26, 2014, 10:43:21 PM3/26/14
to yal...@googlegroups.com
I change all the 'qpOASES' to 'qpoases' and get:

>> mpc_simple
lb =
 -1.#INF000000000000e+000   
 -1.#INF000000000000e+000   
 -1.#INF000000000000e+000   
 -1.#INF000000000000e+000   

Error using qpoases
ERROR (qpOASES): Input dimension mismatch for argument 9 ([1,1] ~= [4,1]).

Error in callqpoases>callsolver (line 70)

[x,fval,exitflag,iter,lambda] = qpoases(model.Q, model.c, A,
model.lb,model.ub,lbA,ubA,[],options.qpoases);

Error in callqpoases (line 14)

solution = callsolver(model,options);

Error in solvesdp (line 355)
    eval(['output = ' solver.call '(interfacedata);']);

Error in mpc_simple (line 37)
      solvesdp(CON,OBJ,sdpsettings('debug',1,'verbose',2,'solver','qpoases'))



>> which qpoases -all
C:\cygwin64\home\cezou\qpOASES-3.0beta\interfaces\matlab\qpoases.mexw64
C:\cygwin64\home\cezou\qpOASES-3.0beta\interfaces\matlab\qpoases.m       % Shadowed
>>

Eric

unread,
Mar 26, 2014, 10:47:27 PM3/26/14
to yal...@googlegroups.com
it seems complex. I am not sure whether it will be OK if I re-install it.
Message has been deleted
Message has been deleted

Johan Löfberg

unread,
Mar 27, 2014, 2:59:30 AM3/27/14
to yal...@googlegroups.com
Well, looks like qpoases has crashed. Unless you aren't in academia, I can only advice you to install a competent QP solver such as cplex, gurobi, or mosek.

Johan Löfberg

unread,
Mar 27, 2014, 3:02:09 AM3/27/14
to yal...@googlegroups.com
I don't understand your comment about soc_max


Your call to optimizer is not correct. The *two* final arguments should either two matrices, or two cells containing all parameters and solutions to be returned.

help optimizer


Eric

unread,
Mar 27, 2014, 9:13:15 AM3/27/14
to yal...@googlegroups.com
Thank you, Johan, now I am using cplex. Things are going well. 

Dominik Moser

unread,
Apr 18, 2014, 5:08:48 AM4/18/14
to yal...@googlegroups.com
Hello, thanks for that awesome toolbox!

I also want to use the qpoasis solver for my problem. Is there an older, stable version of YALMIP which works with qpoases?

Thank you very much!
Dominik

Johan Löfberg

unread,
Apr 18, 2014, 5:22:42 AM4/18/14
to yal...@googlegroups.com
Why would you want to use an older version?

YALMIP has interfaced qpoasis for several years, so there are many old versions supporting it.

Dominik Moser

unread,
Apr 18, 2014, 5:52:23 AM4/18/14
to yal...@googlegroups.com
Because the newest version of yalmip is not compatible with qpoases. I get the same error, also with not case sensitive versions (2011a) of matlab. I think there is a problem when generating the parameters for qpoases, as you can see in the error message below.

??? Error using ==> qpOASES
ERROR (qpOASES): Input dimension mismatch!

Error in ==> callqpoases>callsolver at 71
[x,fval,exitflag,iter,lambda] = qpOASES(model.Q, model.c, A,
model.lb,model.ub,lbA,ubA,[],options.qpoases);

Error in ==> callqpoases at 15
solution = callsolver(model,options);

Error in ==> optimizer.subsref at 121
            output = self.model.solver.callhandle(self.model);

Error in ==> TestMPC_YALMIP_Fahrzykl at 81
    uopti=controller{xopt};

Johan Löfberg

unread,
Apr 18, 2014, 5:55:20 AM4/18/14
to yal...@googlegroups.com
It is explained above in this thread how to fix this (fix the call in callqpoases to avoid the problems)

Johan Löfberg

unread,
Apr 18, 2014, 5:57:47 AM4/18/14
to yal...@googlegroups.com
didn't read your full post

does it fail o n every problem, or just one particular. Does yalmiptest('qpoases') run cleanly?

Dominik Moser

unread,
Apr 18, 2014, 6:15:11 AM4/18/14
to yal...@googlegroups.com
Yes, it fails also at the mpc example from the yalmip homepage. yalmiptest runs not cleanly: qpoases found, no problem. If i enter yalmiptest('qpoases') i get again the same error message at the QP and LP Tests:
Unknown problem in solver (try using 'debug'-flag in sdpsettings) (Error using ==> qpOASES
ERROR (qpOASES): Input dimension mismatch!)|

Johan Löfberg

unread,
Apr 18, 2014, 6:19:39 AM4/18/14
to yal...@googlegroups.com
I see they have release 3.0. YALMIP only supports 2.0 at the moment. Will try to add support for 3.0 in the next release

Johan Löfberg

unread,
Apr 18, 2014, 6:21:46 AM4/18/14
to yal...@googlegroups.com
Correction: YALMIP supports 3.0 from august 2011, but not the latest 3.0 release from april 2014. They must have changed something in their interface despite keeping the version number.

Dominik Moser

unread,
Apr 18, 2014, 8:41:19 AM4/18/14
to yal...@googlegroups.com
Ok, thank you very much. I will wait for it. qpOASES 2.0 is also not compatible with yalmip. Can you tell me roughly when the next version will be released?

Johan Löfberg

unread,
Apr 18, 2014, 9:18:19 AM4/18/14
to yal...@googlegroups.com
I downloaded the april version to see if there was any easy fix, but it did not contain any compiled version for windows, and I don't have any compiler

I don't have any time plan. qpoasis support is very low priority, but if it easy to fix and I get hold of a compiled version to test, it should be included in the next release which should be in some weeks

Fastest for you is probably just to see what is wrong with the data that YALMIP sends in callqpoasis and fix the call accordingly

Dominik Moser

unread,
Apr 18, 2014, 3:17:08 PM4/18/14
to yal...@googlegroups.com
I was looking at the code "callqpoases.m" and i think the problem are the solver options. The new qpOASES needs to get a [1,1] struct containing the options. Unfortunately the qpOASES_options() command returns a struct which has also the wrong dimensions. At the moment, I don't know how to pass any options to qpOASES... Maybe there is a bug in the qpOASES software.
Anyway, I run the code without passing any options to qpOASES, and it works.


Reply all
Reply to author
Forward
0 new messages