Report my confusions/errors when finding a feasible solution of a simple LMI given in the tutorials page

89 views
Skip to first unread message

Can Li

unread,
Jul 19, 2017, 9:37:47 PM7/19/17
to YALMIP
Hi  Johan,

I have some confusions on the simple example of LMI feasible solution given in https://yalmip.github.io/tutorial/semidefiniteprogramming/

when i use the same code (copied from the above link page) posted below:

A = [-1 2 0; -3 -4 1; 0 0 -2];
P = sdpvar(3,3);
F = [P >= 0, A'*P+P*A <= 0];
optimize(F); % for a feasible solution only
Pfeasible = value(P)

It reports errors:

error using: lmi/subsref (line 76)
Indexing type not supported

error in: optimize (line 14)
    diagnostics =
    solvesdp(OptimizationProblem.Constraints,OptimizationProblem.Objective,OptimizationProblem.Options);
    
error in: sdpex (line 17)
optimize(F);

The same errors happen when i add an objective function as

A = [-1 2 0; -3 -4 1; 0 0 -2];
P = sdpvar(3,3);
F = [P >= 0, A'*P+P*A <= 0];
obj = -P;
optimize(F,obj);
Pfeasible = value(P)

But it works as i try (replace 'optimize' by 'solvesdp')

A = [-1 2 0; -3 -4 1; 0 0 -2];
P = sdpvar(3,3);
F = [P >= 0, A'*P+P*A <= 0];
obj = -P;
solvesdp(F,obj);
Pfeasible = value(P)

or

A = [-1 2 0; -3 -4 1; 0 0 -2];
P = sdpvar(3,3);
F = optproblem([P >= 0, A'*P+P*A <= 0], -P);
optimize(F);
Pfeasible = value(P)

this two codes give the same result
Pfeasible =

    1.0000    0.0723   -0.0091
    0.0723    0.3667    0.0524
   -0.0091    0.0524    0.5725

My problem is: why the first two codes do not work and report errors? Because they are copied from https://yalmip.github.io/tutorial/semidefiniteprogramming/
Should i always add an objective function even if i only need a feasible solution of LMIs?

Thanks for your attention!


Johan Löfberg

unread,
Jul 20, 2017, 3:22:47 AM7/20/17
to YALMIP
You've messed something up when reporting the error or something. The error you show is happening in optproblem/optimize, but you claim the optproblem approach works

My guess is that you have some weird mix of old and new variables or something. Make sure you clean your work-space before running the test

Can Li

unread,
Jul 20, 2017, 4:22:03 AM7/20/17
to YALMIP
Thanks! i try it by adding ‘clear all’ at the beginning of the code. But the errors still exist. 

clear all
A = [-1 2 0; -3 -4 1; 0 0 -2];
P = sdpvar(3,3);
F = [P >= 0, A'*P+P*A <= 0];
optimize(F);
Pfeasible = value(P)

error using: lmi/subsref (line 76)
Indexing type not supported

error in: optimize (line 14)
    diagnostics =
    solvesdp(OptimizationProblem.Constraints,OptimizationProblem.Objective,OptimizationProblem.Options);
    
error in: sdpex (line 5)
optimize(F);

Johan Löfberg

unread,
Jul 20, 2017, 4:48:56 AM7/20/17
to YALMIP
It still goes into an optproblem method (line 14 references line 14 in optproblem/optimize)

You must have something massively wrong with your installation

Run and report

yalmip('ver')
which optimize -all
path
type sdpex.m

Can Li

unread,
Jul 20, 2017, 5:01:23 AM7/20/17
to YALMIP
The information are posted below ('path' follows too many items, so i just give that relate to YALMIP)
>> yalmip('ver')

ans =

20170626

>> which optimize -all
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\extras\optimize.m
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\extras\@optproblem\optimize.m                % optproblem method
C:\Program Files\MATLAB\R2016a\toolbox\mbc\mbcview\@cgnormnode\optimize.m                  % cgnormnode method
C:\Program Files\MATLAB\R2016a\toolbox\sldo\sloptim\sloptim\@ResponseOptimizer\optimize.m  % ResponseOptimizer method

>> path

MATLABPATH

D:\文档\MATLAB
D:\文档\MATLAB\sedumi
D:\文档\MATLAB\sedumi\conversion
D:\文档\MATLAB\sedumi\doc
D:\文档\MATLAB\sedumi\examples
D:\文档\MATLAB\sedumi\o_win
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\modules\sos
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\modules\robust
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\modules\global
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\modules\moment
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\modules\parametric
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\operators
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\modules
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\solvers
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\demos
C:\Program Files\MATLAB\R2016a\toolbox\yalmip
C:\Program Files\MATLAB\R2016a\toolbox\yalmip\extras

>> type sdpex.m

clear all
A = [-1 2 0; -3 -4 1; 0 0 -2];
P = sdpvar(3,3);
F = optproblem([P >= 0, A'*P+P*A <= 0], -(P));
% F = [P >= 0, A'*P+P*A <= 0];
optimize(F);
Pfeasible = value(P)

Johan Löfberg

unread,
Jul 20, 2017, 5:25:09 AM7/20/17
to YALMIP
You said if failed when you used the standard approach (I never use optprolem and it is essentially an obsolete/unofficial feature), but in your code you are using optproblem, so you are still not consistently reporting what you are doing and what is happening

Before proceeding, restart matlab. I've never seen this error, and it makes no sense

Change you sdpex to this, run and report everything displayed

clear all
A = [-1 2 0; -3 -4 1; 0 0 -2];
P = sdpvar(3,3);
F = [P >= 0, A'*P+P*A <= 0]
class(F)
methods(F)
optimize(F,[],sdpsettings('debug',1))



...and having -P as objective in your optproblem does not make sense (it should be a scalar)

Can Li

unread,
Jul 20, 2017, 6:20:26 AM7/20/17
to YALMIP
Here is the result displayed: (still report errors)

>> sdpex
++++++++++++++++++++++++++++++++
|   ID|              Constraint|
++++++++++++++++++++++++++++++++
|   #1|   Matrix inequality 3x3|
|   #2|   Matrix inequality 3x3|
++++++++++++++++++++++++++++++++

ans =

lmi


Methods for class lmi:

Polyhedron                
and                       
assignschur               
boundingbox               
categorizeproblem         
chanceconstraint          
chebyball                 
check                     
checkset                  
clear_poly_dep            
cleardual                 
colon                     
complements               
constraintclass           
convertlorentz            
convertsocp               
cut                       
depends                   
display                   
dissect                   
double                    
dual                      
eliminateBinary           
ellipsoid                 
end                       
envelope                  
eq                        
expanded                  
expandmeta                
extractRandomDefinitions  
fastcat                   
flatten                   
getComplementarityTerms   
getbase                   
getbounds                 
getbounds_interval        
getcutflag                
getlmiid                  
getlrdata                 
getvariables              
groupchanceconstraints    
horzcat                   
hull                      
imag2reallmi              
imagemodel                
indicators                
is                        
isfeasible                
isinterval                
islinear                  
ismember                  
isnan                     
isreal                    
isrelaxfeasible           
issigmonial               
kkt                       
length                    
lifted                    
linearize                 
lmi                       
lmi2sedumistruct          
lmiinfo                   
lmior                     
loadobj                   
logic2cont                
lowrank                   
minus                     
or                        
plot                      
plotlattice               
plus                      
polytope                  
problemclass              
projection                
pwamodel                  
reduce                    
remap                     
replace                   
saveobj                   
sdpvar                    
see                       
set                       
setcutflag                
setdualize                
settype                   
setupMeta                 
shift                     
size                      
sizeOLD                   
sosd                      
spy                       
subsasgn                  
subsref                   
tag                       
uncertain                 
uplus                     
usedvariables             
value                     
variablereplace           
vertcat                   


Error using optimize
Too many input arguments.

Error in sdpex (line 7)
optimize(F,[],sdpsettings('debug',1))

Johan Löfberg

unread,
Jul 20, 2017, 6:49:27 AM7/20/17
to YALMIP
For some bizarre reason, the wrong optimize method is called (optproblem method even when you don't use optprolem objects). Something is broken

Edit optproblem/optimize and add this before the if-statement, run sdpex and report what is displayed

dbstack


Johan Löfberg

unread,
Jul 20, 2017, 6:50:37 AM7/20/17
to YALMIP
and run yalmiptest and report the answer

Can Li

unread,
Jul 20, 2017, 7:37:21 AM7/20/17
to YALMIP


Can Li

unread,
Jul 20, 2017, 7:40:42 AM7/20/17
to YALMIP
The same errors reported. Should i reinstall the YALMIP?

Johan Löfberg

unread,
Jul 20, 2017, 8:01:39 AM7/20/17
to YALMIP
Remove the directory extras/@optproblem

Johan Löfberg

unread,
Jul 20, 2017, 8:02:01 AM7/20/17
to YALMIP
That is the first thing you should have tried. I assumed you already had try to delete everything and installed from scratch

Can Li

unread,
Jul 20, 2017, 8:42:38 AM7/20/17
to YALMIP
Yes! The problem is now solved by reinstalling the YALMIP. 

Thank you so much!

Johan Löfberg

unread,
Jul 20, 2017, 9:07:14 AM7/20/17
to YALMIP
OK, great

It would have been interesting to have understood what caused this issue, very mysterious, but too late now

Can Li

unread,
Jul 20, 2017, 10:30:02 AM7/20/17
to YALMIP
May be something lost when the first installation, because I install and use this tool just yesterday. I choose YALMIP for its ability to process equality constraints and it seems more convenient to solve LMIs than the traditional one.

I have another question that how can i transform an Element-wise inequality to a Linear matrix one? For example, using the traditional LMI tool, one can realize it by writhing 0.5*(A'+A)<0 to replace A<0 (matrix A may not be symmetric). 

I have tried it in YALMIP but failed. 

Johan Löfberg

unread,
Jul 20, 2017, 1:06:37 PM7/20/17
to YALMIP
If you have a non-symmetric matrix A and you want it to have non-negative values, you write A<=0. If you want the unsymmetric matrix A to satisfy v'Av<=0 for all v, then you have to symmetrize it and write A+A' <= 0. If you want the unsymmetric matrix A to have non-positive eigenvalues, you jhave problems because that is a  very hard nonconvex constraint and not an LMI.
Reply all
Reply to author
Forward
0 new messages