# Error using Mosek Solver with binary constraints

I am trying to solve the following optimization problem with binary variables using a Mosek solver in MATLAB R2012b and Windows 10 OS.
n1=6;n2=3
A=rand(n1,n1);
cvx_begin
variable x(n1,n1) diagonal binary
minimize lambda_max(AxA’)
subject to
sum(sum(x))=n2
cvx_end

And I get the following error

Error:
Reference to non-existent field ‘sol’.
Error in G:\Other Stuff\Softwares\cvx\shims\cvx_mosek.p>solve
(line 490)

Error in cvxprob/solve (line 428)
[ x, status, tprec, iters ] = shim.solve( At, b, c,
cones, quiet, prec, solv.settings, eargs{:} );

Error in cvx_end (line 87)
solve( prob );

First, the above problem gives a optimum solution for n1=2 and n2=1. For n1>3 the above error is displayed.
Later I attempted to solve the problem by reformulating in the below given way to get a solution which is binary (0 or 1). I am able to run the cvx without any errors But it doesn’t return a binary solution x for every matrix A. Any suggestions to solve the above given problem using binary restrictions on variables?

n1=6; n2=3;
cvx_begin
variable x(n1,n1) diagonal nonnegative
minimize lambda_max(AxA’)
subject to
sum(sum(x))==n2
norm(x,Inf)<=1
cvx_end

I found a way to solve the above problem using YALMIP. I came to know that, CVX with Mosek solver (academic license) cannot handle binary semidefinite variables. Below given is the mosek error displayed in matlab.
Mosek error: MSK_RES_ERR_GLOBAL_INV_CONIC_PROBLEM (The global optimizer can only be applied to problems without semidefinite variables.)

Whereas YALMIP can handle binary semidefinite variables. I have solved using the following code.

n1=5;n2=3;
A=rand(n1,n1)
x = diag(binvar(n1,1));
F = [sum(sum(x))==n2];
h = lambda_max(AxA’);
optimize(F,h);
sol = value(x)

Yalmip has implemented its own B&B to my knowledge. That is why Yalmip can solve it.

For Mosek error: MSK_RES_ERR_GLOBAL_INV_CONIC_PROBLEM (The global optimizer can only be applied to problems without semidefinite variables.)

The reason behind that is, you are trying to implement a mixed integer solution along with normal Semidefinite Program, which Mosek doesn’t allow. So try to remove the line:

“prob.ints.sub”

Removing this, I got my solution, though I had to solve the Mixed Integer part through the Second Order Cone Program and thereby used those values accordingly to solve my Semidefinite Program.

I have faced similar problem and I cannot understand why mosek doesn’t allow, according to CVX 7th and later versions of MOSEK should allow.
and I did not understand where should I remove the line “prob.ints.sub”

MOSEK, even the forthcoming version 9.0, does not natively handle mixed-integer SDPs, but does handle mixed-integer SOCPs (among other things). Read the link Mixed Integer SDPs which are not Mixed Integer SOCPs provided above.

hello
i want to write a mixed-integer SDP.
is there any toolbox to do that in cvx?

There is no way of solving mixed-integer SDPs in CVX. Mosek can handle mixed-integer combined with all cone types, except semidefiinite. Depending on the code, CVX can actually send something to Mosek, but Mosek would produce an error message.

Mixed-integer SDP can done in YALMIP, using either

1. YALMIP’s BNB solver, with Mosek or other semidefinite solver as uppersolver.
or
2. YALMIP"s cutsdp, combined with MILP solver

thank you so much for answering

There is sort of an exception. If CVX can convert the semidefinite constraints into SOCP constraints, as for instance with any 2 by 2 semidefinite constraints, then it would pass the problem to Mosek as an MISOCP, and MOsek could solve it.

For instance,

``````cvx_begin
cvx_solver mosek
variable X(2,2) integer symmetric
;minimize(trace(X))
X >=2
X==semidefinite(2)
cvx_end
``````

CVX 2.2 disallows declaration of semidefinite and (integer or binary).

Here is an old post on the subject from the CVX developer

yes
it worked for me when dimensions were (2,2) but change to (3,3) caused error.
unfortunately bnb with mosek or other semidefinite solvers as uppersolver didn’t work for me.
but I didn’t understand your meaning about combined cutsdp with MILP solver.
can you guide me?

I know how to do it, but this is not the appropriate forum for that.

You need to read https://yalmip.github.io/tutorial/basics/ , and then seek any further help at https://groups.google.com/g/yalmip .