'Model creation failed (Model not available in constraint #39 at level 1)'

572 views
Skip to first unread message

liuyan...@gmail.com

unread,
Feb 1, 2018, 1:03:08 PM2/1/18
to YALMIP
Dear All
I am using yalmip to formualte a MINLP problem, part of the  code are:

Ubus=sdpvar(31,1,'full','complex');
Istat=sdpvar(31,1,'full','complex');
Qstat=intvar(30);
for j=1:32
con=[con,AFIN(j,:)*[Istat;Ubus]==b0(j,1)];
end
con=[con,abs(Ubus(21,1))-1==0];
 for busnumber=1:30
    con=[con,abs(Ubus(busnumber,1))-1.1<=0];
     if busnumber~=1&&busnumber~=2&&busnumber~=5&&busnumber~=8&&busnumber~=11&&busnumber~=13   
     con=[con,real(Ubus(busnumber,1)*conj(Istat(busnumber,1)))==0,abs(Istat(busnumber,1))-(Qstat(busnumber)/100)<=0];
     
      else
          con=[con,Istat(busnumber,1)==0];
     end


but I got the error: 'Model creation failed (Model not available in constraint #39 at level 1)'.

I think it may be caused by 
for j=1:32
con=[con,AFIN(j,:)*[Istat;Ubus]==b0(j,1)];
end
where AFIN is a matrix with known cofficients(complex number)

Can anyone help with this? Urgent, thanks!!!!
And also is there any recommendation about which solver should I use?

Johan Löfberg

unread,
Feb 1, 2018, 1:24:01 PM2/1/18
to YALMIP
You would have to supply more information to get a specific answer

This error occurs when you use an convexity aware operator inside another operator which doesn't satisfy convexity rules

Example
>> x = sdpvar(1,1,'full','complex')
Linear scalar (complex, 2 variables)
>> optimize(abs(1 + abs(x)) <=0)

ans = 

    solvertime: 0
       problem: 14
          info: 'Model creation failed (Model not available in constraint #1 at level 2)'
    yalmiptime: 0.0890


absolute value of complex variable is a convex SOCP-represented operator. abs function applied  abs is not necessarily convex per convexity propagation rules, hence the inner abs cannot be modelled using an SOCP epigraph, and there is no general fallback in the abs operator (so one would have to replace it with sqrtm(real(x)^2 + imag(x)^2) instead and go the nonlinear programming route instead
Message has been deleted

Johan Löfberg

unread,
Feb 1, 2018, 2:36:50 PM2/1/18
to YALMIP
impossible to see in that code without being able to run it.

btw, are you aware that you define Qstat to  be a 30x30 matrix?

real(Ubus(busnumber,1)*conj(Istat(busnumber,1)))==0 is a nonconvex bilinear equality which will make gurobi inapplicable anyway

Johan Löfberg

unread,
Feb 1, 2018, 2:40:27 PM2/1/18
to YALMIP
ah, this is where the message comes from

con=[con,abs(Ubus(21,1))-1==0];

abs is socp-represented thus not possible to use in a nonconvex setting

you will have to solve this using a global nonlinear integer solver (i.e. as bad as it can get, essentially unsolvable) and write the abs by squaring it as x^2+y^2 =1 instead

liuyan...@gmail.com

unread,
Feb 1, 2018, 2:57:41 PM2/1/18
to YALMIP
Thank you so much! I modified the code based on your guidance, to change the variable to real

obj2=0;
Ur=sdpvar(31,1);Ui=sdpvar(31,1);
Ir=sdpvar(31,1);Ii=sdpvar(31,1);
Qstat=intvar(30,1); con=[];

and using

 FIN=[real(AFIN) -imag(AFIN);imag(AFIN) real(AFIN)];
 b4=[real(b0);imag(b0)]; 

to change the cofficient,

and (Ur(21,1))^2+(Ui(21,1))^2-1==0 to replace abs and also other abs used

the real(Ubus(busnumber,1)*conj(Istat(busnumber,1)))==0 is also transformed
as Ir(busnumber,1)*Ur(busnumber,1)+Ii(busnumber,1)*Ui(busnumber,1)==0

the error model creation failed disappeared but Solver not applicable

So is this because of the non-convexity of Ir(busnumber,1)*Ur(busnumber,1)+Ii(busnumber,1)*Ui(busnumber,1)==0?
Is it possible I could use other solvers to solve this model?

Thank you so much for your help! Really appreciated?

liuyan...@gmail.com

unread,
Feb 1, 2018, 3:10:48 PM2/1/18
to YALMIP
And I deleted the constraints  Ir(busnumber,1)*Ur(busnumber,1)+Ii(busnumber,1)*Ui(busnumber,1)==0 to run it
Still got the Solver not applicable(gurobi)

Could you please tell me why this happened? and if possible,also please  give some recommendations about how to solve this model

Thank you so much for your guidance!! Really appreciated !!!

Johan Löfberg

unread,
Feb 1, 2018, 3:20:15 PM2/1/18
to YALMIP
As I said, bilinear and quadratic equalities are nonconvex, and gurobi etc are not applicable. 

You have a nonlinear nonconvex mixed-integer program, as bad as it gets.

liuyan...@gmail.com

unread,
Feb 2, 2018, 5:52:40 AM2/2/18
to YALMIP
Dear Prof.Johan Lofberg

Thank you so much for your help and answer?

I have modified the code and set the Q as a continuous variable, but the solver still is not applicable.

So is this means that I have to change or transform the constraints   (Ur(21,1))^2+(Ui(21,1))^2-1==0 and  Ir(busnumber,1)*Ur(busnumber,1)+Ii(busnumber,1)*Ui(busnumber,1)==0 to make it solveble?

Thank you again for your help!

Johan Löfberg

unread,
Feb 2, 2018, 6:03:24 AM2/2/18
to YALMIP
Then you till have bilinear/quadratic equalities in your model

cplex/gurobi/mosek etc are for convex problems (except for nonconvexity coming from the combinatorial variables)

With nonconvex things like quadratic equalities, the problem is close to unsolvable. It is a much much harder problem. YALMIP interfaces global solvers such as scip and baron, and has the internal solver bmibnb, but mixed-integer nonconvex nonlinear programs are essentially as hard as an optimization problem can get, and are most often impossible to solve

Johan Löfberg

unread,
Feb 2, 2018, 6:05:01 AM2/2/18
to YALMIP
You should simply look at your model and see where you're doing these bad things. If you cannot see it, you can always display the constraints

>> Model  = [ x*y == 1, x^2 <= 1, y <= 1];
>> Model
++++++++++++++++++++++++++++++++++++++++++++++++++
|   ID|                                Constraint|
++++++++++++++++++++++++++++++++++++++++++++++++++
|   #1|        Equality constraint (bilinear) 1x1|
|   #2|   Element-wise inequality (quadratic) 1x1|
|   #3|               Element-wise inequality 1x1|
++++++++++++++++++++++++++++++++++++++++++++++++++


Reply all
Reply to author
Forward
0 new messages