Problem when solving quadratic program

76 views
Skip to first unread message

wang lingyi

unread,
Sep 23, 2022, 8:12:21 AM9/23/22
to mosek
Hi,

I am currently solving the following quadratic program in Matlab using mosek within yalmip as below. However, every time I run it, the outcome is infeasible ( the third constraint), which really puzzles me. Since the vector "gamma" has no constraints, just being a nonnegative vector bounding the term "A0*g-b0", why the yalmip cannot choose a sufficiently large gamma to satisfy the third constraint? Attached below is my code and data file. Any advice will help. Thank you.


optimize_prb.m
optimize_data.mat

Michal Adamaszek

unread,
Sep 23, 2022, 8:23:27 AM9/23/22
to mosek
Not reproducible. The first error is

Undefined function 'bdiag' for input arguments of type 'double'.

Error in optimize_prb (line 15)
R_blk=full(bdiag(R,L));

I suggest you first wait for the answer in your question on the YALMIP forum (also because you are using some outdated YALMIP syntax we are not so familiar with). And if you would like to know something about the MOSEK part then either save the MOSEK task file and attach here or at least share the MOSEK log output (do not use verbose=0).

Michal

wang lingyi

unread,
Sep 23, 2022, 8:41:50 AM9/23/22
to mosek
Thank you for your reply. I just forgot how to save the task.gz file in Matlab. Could you tell me that command? Attached please find the bdiag function. Sorry for my carelessness.
bdiag.m

Michal Adamaszek

unread,
Sep 23, 2022, 9:07:56 AM9/23/22
to mosek
This is my log output using latest Mosek 10.0. The solution has a bit large violations so it's not all perfect but seems clearly feasible.



Optimizer started.
Quadratic to conic reformulation started.
Quadratic to conic reformulation terminated. Time: 0.00    
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries                  : 1                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.00            
Lin. dep.  - number                 : 0              
Presolve terminated. Time: 0.00    
Problem
  Name                   :                
  Objective sense        : minimize        
  Type                   : QO (quadratic optimization problem)
  Constraints            : 184            
  Affine conic cons.     : 0              
  Disjunctive cons.      : 0              
  Cones                  : 0              
  Scalar variables       : 74              
  Matrix variables       : 0              
  Integer variables      : 0              

Optimizer  - threads                : 64              
Optimizer  - solved problem         : the dual        
Optimizer  - Constraints            : 74
Optimizer  - Cones                  : 1
Optimizer  - Scalar variables       : 241               conic                  : 57              
Optimizer  - Semi-definite variables: 0                 scalarized             : 0              
Factor     - setup time             : 0.00              dense det. time        : 0.00            
Factor     - ML order time          : 0.00              GP order time          : 0.00            
Factor     - nonzeros before factor : 2469              after factor           : 2678            
Factor     - dense dim.             : 0                 flops                  : 1.81e+05        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   2.6e+05  1.0e+00  2.0e+00  0.00e+00   5.000000000e-01   0.000000000e+00   1.0e+00  0.00  
1   1.7e+05  6.4e-01  1.6e+00  -1.00e+00  4.897685473e+01   4.474148999e+01   6.4e-01  0.00  
2   7.5e+04  2.9e-01  1.1e+00  -1.00e+00  2.145277158e+03   2.244887030e+03   2.9e-01  0.00  
3   7.6e+03  2.9e-02  3.4e-01  -1.00e+00  2.298496311e+05   2.523226753e+05   2.9e-02  0.01  
4   2.7e+01  1.0e-04  1.9e-02  -9.99e-01  1.486313510e+10   1.638865741e+10   1.0e-04  0.01  
5   2.0e+00  7.6e-06  2.9e-03  -7.91e-01  3.458872639e+11   3.764570494e+11   7.6e-06  0.01  
6   5.0e-01  1.9e-06  2.8e-04  6.12e-01   6.624398594e+10   6.828999226e+10   1.9e-06  0.01  
7   1.0e-01  3.8e-07  1.9e-05  1.52e+00   1.645365025e+09   1.681820686e+09   3.8e-07  0.02  
8   2.1e-02  7.9e-08  1.7e-06  1.19e+00   6.987597780e+07   7.124611219e+07   7.9e-08  0.02  
9   6.5e-03  2.5e-08  2.8e-07  1.03e+00   2.160308762e+07   2.181530607e+07   2.5e-08  0.02  
10  1.4e-03  5.3e-09  2.6e-08  1.01e+00   1.214853757e+07   1.217810885e+07   5.3e-09  0.02  
11  3.1e-04  1.2e-09  2.6e-09  1.00e+00   1.026103655e+07   1.026651727e+07   1.2e-09  0.02  
12  7.1e-05  2.7e-10  2.8e-10  1.00e+00   9.926297073e+06   9.927485381e+06   2.7e-10  0.02  
13  1.8e-05  6.9e-11  3.6e-11  1.00e+00   9.848170039e+06   9.848469605e+06   6.9e-11  0.02  
14  4.1e-06  1.6e-11  3.9e-12  1.00e+00   9.829087662e+06   9.829155418e+06   1.6e-11  0.02  
15  8.9e-07  3.4e-12  3.9e-13  1.00e+00   9.824314328e+06   9.824329039e+06   3.4e-12  0.02  
16  1.9e-07  7.4e-13  4.0e-14  1.00e+00   9.823290616e+06   9.823293899e+06   7.4e-13  0.02  
17  3.4e-08  1.3e-13  2.9e-15  1.00e+00   9.823054337e+06   9.823054921e+06   1.3e-13  0.02  
18  3.0e-09  1.1e-14  7.9e-17  1.00e+00   9.823011349e+06   9.823011402e+06   1.1e-14  0.02  
Optimizer terminated. Time: 0.02    


Interior-point solution summary
  Problem status  : PRIMAL_AND_DUAL_FEASIBLE
  Solution status : OPTIMAL
  Primal.  obj: 9.8230112807e+06    nrm: 6e+04    Viol.  con: 2e-05    var: 0e+00  
  Dual.    obj: 9.8230114705e+06    nrm: 5e+06    Viol.  con: 4e-01    var: 2e-02  


wang lingyi

unread,
Sep 23, 2022, 10:02:47 AM9/23/22
to mosek
what do you mean by a bit large violation? Constraint not satisfied and violated much?

wang lingyi

unread,
Sep 23, 2022, 10:02:53 AM9/23/22
to mosek
And I am currently using Mosek9.4, if I want to install 10.0, do I need to download the latest version and install again?

在2022年9月23日星期五 UTC+8 21:07:56<Michal Adamaszek> 写道:

Michal Adamaszek

unread,
Sep 23, 2022, 10:05:53 AM9/23/22
to mosek
About violations https://docs.mosek.com/latest/toolbox/debugging-log.html#solution-summary but of course you can check them on the level of your YALMIP model.

Yes, you could download and install the latest version. Although with 9.3 I had very comparable results.

Before you do anything you should first is enable log output (don't use verbose=0) and see how it compares with my log output. Maybe you are actually solving a different problem. Or maybe it is barely feasible and on your machine the balance is tipped towards infeasibility. Comparing the logs would reveal that.

Good weekend,
Michal

wang lingyi

unread,
Sep 23, 2022, 10:07:58 AM9/23/22
to mosek
This is my mosek output, I check the feasibility by using [primalfeas, dualfeas]=check(F), and the primalfeas<0, it turns out to be infeasible.
output2.JPG
output1.JPGoutput3.JPG

在2022年9月23日星期五 UTC+8 21:07:56<Michal Adamaszek> 写道:

wang lingyi

unread,
Sep 23, 2022, 10:11:04 AM9/23/22
to mosek
So you mean in your machine, all the constraints are satisfied, while on my machine, the constraint are violated? Or do I misunderstand anything. I just want to check that are all the constraints satisfied in your machine. Because I find that even if the mosek reports successfully solved, it is infeasible sometimes

Michal Adamaszek

unread,
Sep 23, 2022, 10:22:04 AM9/23/22
to mosek
They are slightly violated in both cases, look at the Viol in solution summary, 3e-2 is a bit, although compared to the norm of the solution maybe not. It depends on you (see the link I sent about interpreting the log; note that there always are violations, the question is how much is too much for you). Both solutions look similar. Well, my YALMIP passes a QP and yours SOCP so we are using two incomparable versions, but that is a YALMIP detail. The check(F) function also belongs to Johan so he will be able to say more about it on the YALMIP forum. I suspect on your machine it solves with slightly higher violations and maybe the check(F) returns slightly different infeasibilities which you rely on in your code. If the problem is numerically hard maybe you should allow larger error margin.

BTW the check(F) function does not say the problem is feasible or not, just what the residuals are https://yalmip.github.io/command/check/

Please see what Johan says. I don't think from MOSEK point of view we can say much more. 


Reply all
Reply to author
Forward
0 new messages