Unknown problem in solver

582 views
Skip to first unread message

Marc Wijnand

unread,
Sep 8, 2015, 7:44:37 AM9/8/15
to YALMIP
I want to calculate the maximum of a function that contains given matrices P, Q, R, K, function f(.,.) that maps from R^(2x1)xR->R and variables x in R^(2x1)
with an elliptic constraint cond.
x=sdpvar(2,1)
ftion
=f(x,K*x)'*P*f(x,K*x)-x'*P*x + (x'*Q*x+(K*x)'*R*(K*x));
cond
=[x'*P*x<=alpha]
optimize(cond,ftion)
I receive following error message:
yalmiptime: NaN
   solvertime: NaN
         info: 'Unknown problem in solver (Turn on 'debug' in sdpsettings) (Error using fmincon (line 716)
Gradient of nonlinear inequality constraints must h...'
      problem: 9
- In the help function of optimize, I can only find that 'problem 9' stands for (unknown problem in solver).
- Line 716 in fmincon reads
if cgrow ~= sizes.nVar || cgcol ~= sizes.mNonlinIneq
  error(message('optimlib:fmincon:WrongSizeGradNonlinIneq', sizes.nVar, sizes.mNonlinIneq))
end

Would the solution be to use an other solver than fmincon? Which one should I use?

Marc Wijnand

unread,
Sep 8, 2015, 7:47:09 AM9/8/15
to YALMIP
Debug in sdpsettings yields
Error using fmincon (line 716)
Gradient of nonlinear inequality constraints must have size 2-by-1.

Johan Löfberg

unread,
Sep 8, 2015, 7:48:39 AM9/8/15
to YALMIP
Reproducible code needed

Marc Wijnand

unread,
Sep 8, 2015, 8:33:36 AM9/8/15
to YALMIP
Sorry for the delay

close all
clear all
clc
f=@(x,u) [0.55*x(1)+0.12*x(2)+(0.01-0.6*x(1)+x(2))*u
              0.67*x(2)+(0.15+x(1)-0.8*x(2))*u];
K=[-0.019 -.1818];
P=[2.8663 0.2882
   .2882 3.6632];
Q=eye(2);
R=1;
alpha=1.1075;

x=sdpvar(2,1)
ftion=f(x,K*x)'*P*f(x,K*x)-x'*P*x + (x'*Q*x+(K*x)'*R*(K*x));
cond=[x'*P*x<=alpha]
ops = sdpsettings('debug',1)
optimize(cond,ftion,ops)


Johan Löfberg

unread,
Sep 8, 2015, 8:39:00 AM9/8/15
to YALMIP
Explicitly select fmincon as solver and it works (YALMIP messes up and initially converts to an SOCP cone, but then forgets this when it uses fmincon

optimize(cond,ftion,sdpsettings(ops,'solver','fmincon'))


Marc Wijnand

unread,
Sep 17, 2015, 10:37:55 AM9/17/15
to YALMIP
Whit this addition, there is no error message anymore. But as maximum (and minimum), I obtain 0 and the message that the initial point was already a local minimum. However, the origin is clearly not the global maximum (see Figure). I think that the solution would be to use an other starting point. How can I include this in 
optimize
?

Figure: Z-axis shows ftion as function of 2D variable x=[x1,x2]. Points that belong to the ellipse cond are coloured (not black).

Johan Löfberg

unread,
Sep 17, 2015, 11:50:25 AM9/17/15
to YALMIP
Use assign

>> assign(x,randn(2,1));
>> optimize(cond,ftion,sdpsettings('solver','fmincon','usex0',1))

The problem is easy enough for YALMIPs global solver to solve it globally
>> optimize([cond,-10<=x<=10],ftion,sdpsettings('solver','bmibnb','bmibnb.uppersolver','fmincon'))
* Starting YALMIP global branch & bound.
* Branch-variables : 2
* Upper solver     : fmincon
* Lower solver     : GUROBI
* LP solver        : GUROBI
 Node       Upper      Gap(%)       Lower    Open
    1 :   -5.111E-01    10.12     -6.721E-01   2  Improved solution  
    2 :   -5.111E-01    10.12     -6.721E-01   1  Infeasible  
    3 :   -5.111E-01     0.55     -5.194E-01   2    
* Finished.  Cost: -0.51106 Gap: 0.54826
* Timing: 27% spent in upper solver (2 problems solved)
*         2% spent in lower solver (6 problems solved)
*         48% spent in LP-based domain reduction (43 problems solved)




Marc Wijnand

unread,
Sep 18, 2015, 9:25:19 AM9/18/15
to YALMIP
Thanks again.
My last problem is the fact that, depending on the chosen starting point, fmincon will return the correct maximum or an other number that is not the maximum. Is this a normal phenomenon when using fmincon for the minimization of a nonlinear function with quadratic constraints? I really want to be able to find the (global) maximum of the function automatically, without manually looking for a suitable starting point, because the whole optimization will later be executed inside a for loop.

Johan Löfberg

unread,
Sep 18, 2015, 10:15:37 AM9/18/15
to yal...@googlegroups.com
It is a nonconvex problem so all you can hope for when using a standard nonlinear local solver is a locally optimal point. If you are lucky, it is the globally optimal, but even if it is, you have no way of knowing this.

For global solution, you have to accept the computational implications (intractable in the general case) and use a global solver. However, as I just showed you, YALMIP internal global solver solves this problem easily.
Reply all
Reply to author
Forward
0 new messages