# Unable to solve convex problem with CVX and MOSEK

I am solving a convex problem in CVX 2.2 with Mosek 9.1.9. But every time it fails.
The following is the output. Could you please tell me what is wrong here. I think this problem abides by the DCP ruleset.
cvx_begin
cvx_precision default
cvx_solver mosek
variables obj(1) rho(n*m,1) p_ub(K,1) x(K,1)
minimize (obj)
rho’c + sqrt(p0/(1-p0))norm(COV_crho,2) <= obj;
for l = 1:K
0.5
x(l)log(p1) - 0.5log(1-p_ub(l)) + log(V(l)) <= log(xi(l) - rho’*d{l});
x(l)*log(p1) <= log(p_ub(l));
end
sum(x) == 1;
x >= 0;
rho’*A == (1-alpha)*gamma’;
rho >= 0;
cvx_end
CVX Warning:
Models involving “log” or other functions in the log, exp, and entropy
family are solved using an experimental successive approximation method.
This method is slower and less reliable than the method CVX employs for
other models. Please see the section of the user’s guide entitled
The successive approximation method
for more details about the approach, and for instructions on how to
suppress this warning message in the future.

## Calling Mosek 9.1.9: 1152 variables, 531 equality constraints For improved efficiency, Mosek is solving the dual problem.

MOSEK Version 9.1.9 (Build date: 2019-11-21 11:34:40)
Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

Problem
Name :
Objective sense : min
Type : CONIC (conic optimization problem)
Constraints : 531
Cones : 31
Scalar variables : 1152
Matrix variables : 0
Integer variables : 0

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 1
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 : min
Type : CONIC (conic optimization problem)
Constraints : 531
Cones : 31
Scalar variables : 1152
Matrix variables : 0
Integer variables : 0

Optimizer - solved problem : the primal
Optimizer - Constraints : 529
Optimizer - Cones : 32
Optimizer - Scalar variables : 1152 conic : 642
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 : 2.17e+04 after factor : 2.46e+04
Factor - dense dim. : 83 flops : 1.44e+06
ITE PFEAS DFEAS GFEAS PRSTATUS POBJ DOBJ MU TIME
0 1.5e+01 4.9e+01 6.2e+02 0.00e+00 6.130126956e+02 -3.000000000e+00 1.0e+00 0.00
1 1.5e+01 4.9e+01 6.2e+02 -5.93e+00 6.130126956e+02 -3.000000000e+00 1.0e+00 0.00
2 1.5e+01 4.9e+01 6.2e+02 -5.93e+00 6.130126956e+02 -3.000000000e+00 1.0e+00 0.02
Optimizer terminated. Time: 0.02

Interior-point solution summary
Problem status : UNKNOWN
Solution status : UNKNOWN
Primal. obj: 6.1301269559e+02 nrm: 2e+03 Viol. con: 7e+03 var: 0e+00 cones: 0e+00
Dual. obj: -3.0000000000e+00 nrm: 1e+00 Viol. con: 0e+00 var: 5e+01 cones: 0e+00
Optimizer summary
Optimizer - time: 0.02
Interior-point - iterations : 3 time: 0.02
Basis identification - time: 0.00
Primal - iterations : 0 time: 0.00
Dual - iterations : 0 time: 0.00
Clean primal - iterations : 0 time: 0.00
Clean dual - iterations : 0 time: 0.00
Simplex - time: 0.00
Primal simplex - iterations : 0 time: 0.00
Dual simplex - iterations : 0 time: 0.00
Mixed integer - relaxations: 0 time: 0.00

Status: Failed
Optimal value (cvx_optval): NaN

Please try with more recent Mosek (10.1.16 is the last one).

Please don’t use `cvx_precision`.

If that doesn’t help please either post a fully reproducible example with input data or save the task file (1 Technical Issues — MOSEK FAQ 10.1.15) and send to Mosek support

Download the latest stable Mosek version, currently 10.1.16, from the Mosek werbsite. You can use that instead of Mosek 9.1.9, which is bundled with CVX 2.2…

To make sure you don’t wind up using Mosek 9.1.9 which is bundled with CVX 2.2:

Download the latest Mosek from the Mosek werbsite and install it under MATLAB. Make sure `mosekdiag` succeeds. Then reinstall CVX so it will find the new solver.

Either delete or rename the mosek directory under CVX (before reinstalling CVX)
or
`cvx_solver` shows all the versions of all the solvers available to CVX. Choose the Mosek 10.x version, which might be called something like Mosek_2, then use `cvx_solver Mosek_2` to get that version, and you can `save_prefs`.

In any event, `cvx_solver` will show all the versions available to CVX.

1.First problem: My MOSEK version: 10.1.16 was installed successfully in the command line window, but the version displayed under cvx_solver was not correct.
mosekdiag
Matlab version : 9.11.0.1769968 (R2021b)
Architecture : PCWIN64
mosekopt path : C:\Program Files\Mosek\10.1\toolbox\r2017aom\mosekopt.mexw64
MOSEK version : 10.1.16
Test linear solve: Success
mosekopt works OK. You can use MOSEK in MATLAB.
>> cvx_solver

• Name Status Version Location*
-----------------------------------------------------------------------------------------
• Mosek 9.1.9 {cvx}\mosek\w64*
• Mosek_2 9.1.9 C:\Program Files\Mosek\10.1\toolbox\r2017aom*
• Mosek_3 9.1.9 C:\Program Files\Mosek\10.1\toolbox\r2017aom*
• Mosek_4 9.1.9 C:\Program Files\Mosek\10.1\toolbox\r2017a*
• Mosek_5 10.0.46 C:\Users\daily\mosek\10.0\toolbox\r2017a*
• Mosek_6 10.0.46 C:\Users\daily\mosek\10.0\toolbox\r2017a*
• Mosek_7 10.0.46 C:\Users\daily\mosek\10.0\toolbox\r2017aom*
• Mosek_8 10.0.46 C:\Users\daily\mosek\10.0\toolbox\r2017aom*
• SDPT3 selected,default 4.0 {cvx}\sdpt3*
• SeDuMi 1.3.4 {cvx}\sedumi*

2.The second question is in the cvx code section, how should we choose the version?
code:
‘*cvx_begin *
cvx_solver mosek
, then the command line indicates: MOSEK Version 9.1.9 (Build date: 2019-11-21 11:34:40)

Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com

Platform: Windows/64-X86
Which version are we using at this point? Is it MOSEK version: 10.1.16?

The version 9.1.9 displayed by CVX is wrong. I never quite understood why it does that. You can always trust the version printed by Mosek itself in the summary and also in the log when it starts solving.

Judging from your list you should choose `cvx_solver Mosek_2` to get Mosek 10.1

Thank you very much for your help

I installed Mosek for Windows(64bit x 86) from link Mosek - Downloads , but after installation In MATLAB command window, if I type mosekdiag or msktestlic getting as Unrecognized function or variable ‘mosekdiag’ or Unrecognized function or variable ‘msktestlic’ respectively. Also, if I type C:\Users\Rajashekhar\mosek\10.1\tools\platform\win64x86\bin

Invalid use of operator.
Even I restarted MATLAB, not solved

Most likely you did not add Mosek to the Matlab path. When you do it then `mosekdiag` will be available in matlab. The instructions are in

https://docs.mosek.com/latest/toolbox/install-interface.html

Trying to run `msktestlic` or some binaries inside matlab is pointless, these can be used in the command line (of the operating system), they are not matlab scripts.

I am not getting how to Check that the path
\mosek\10.1\tools\platform<PLATFORM>\bin
was added to the OS variable PATH or not.

Also, in MATLAB command window if I type
Warning: Name is nonexistent or not a directory:
C:\Users\Rajashekhar\mosek\10.1\toolbox\r2017a

In path (line 109)
I am getting above one. And also still getting
Unrecognized function or variable ‘mosekdiag’ in matlab if run mosekdiag. Please help me. Only if I run the msktestlic in the command prompt saying A license was checked out correctly.

We don’t know how your installation looks like, so we cannot confirm if the path

``````C:\Users\Rajashekhar\mosek\10.1\toolbox\r2017a
``````

exists or not on your computer. Maybe you installed Mosek elsewhere, like in Program Files. You must add the path that actually exists.

Sir, I downloaded & installed latest version of Mosek in the folder "C:\Users\Rajashekhar" . Is it fine or I have to install in "C:\Program Files\MATLAB" only?

Also, what is the meaning of OS variable `PATH` , is it command prompt or something else?

Also, which mosek installer is better is install for windows i.e. Windows, MSI installer or Windows, Manual installation?

You can install Mosek anywhere you like, using any installer. It makes no difference, you choose. If you use the MSI installer the PATH will be set for you, and the only thing you have to do is “addpath” in Matlab and setting up the license.

Here is more about environment variables What are PATH and other environment variables, and how can I set or use them? - Super User

I think Windows administration issues are a bit out of the scope of this CVX forum. If you have trouble installing Mosek you can for example ask at the Mosek forum https://groups.google.com/g/mosek or write an email to support or check the troubleshooting section in the installation manual.

If you installed Mosek where you claim you did, but you don’t have the toolbox folder then maybe you installed the 32bit version instead of the 64bit.

Dear sir, Thank you. now it is working.

Also, here cvx_solver Mosek_2 I need to select right (not Mosek_3) to get latest version?
Also even with the latest Mosek_2 version, I am not getting even accurate result and also even simulation run-time in MATLAB is also same as that of earlier version of Mosek 9.1.9? But usually latest Mosek_2 version should perform better right??

Also, when I restarted MATLAB, showing

mosekdiag
Unrecognized function or variable ‘mosekdiag’.

But latest version cvx_solver mosek_2 is selected. This is fine right? No need to make any further changes right?

It didn’t find `mosekdiag` because after Matlab restart you have to add Mosek to the path again, or add it to some permanent Matlab path.