Using cvx in a MATLAB .dll


I have an convex optimization problem which I use MATLAB and CVX for and as long as I do this simply in MATLAB alone, everything works like a charm. Now the problem is, I need my MATLAB functions available in C#, so I compile a library of my code. As long as I use only functions from my library which do not use CVX, all is fine.

The problem now lies in the combination of everything, when I want to use functions from my library which make use of CVX. I get the following error:

Attempt to reference field of non-structure array.
at cvx_global.m, line 76. (osolvers = cvx___.solvers.list;)
at cvxprob.m, line 4.
at cvx_begin.m, line 41

I suspect (and I didn’t use CVX for long, so my thought might go into the totally wrong direction) that the MATLAB compiler uses all cvx .m files which my files depend on and then compiles those and includes them in the library. But maybe some files/data is lost in this structure that was setup when doing cvx_setup?
Do I need to inlcude some additional special files?

Using cvx_setup from within my library also results in:

Searching for solvers…
UNEXPECTED ERROR: --------------------------------
Attempt to reference field of non-structure array.
Error in cvx_setup (line 114) (nrej = sum(~cellfun(@isempty,{solvers.error})):wink:

This is really important for my project, so any help will be super appreciated!

I’m afraid it can’t be done.

Thanks for your reply! Too bad, I really liked using CVX, now I need to find something else.

What if you get the same error consistently on a cluster, where cvx is run through MATLAB?

Error in cvx_global (line 76)
osolvers = cvx___.solvers.list;

Error in cvxprob (line 4)

Error in cvx_begin (line 41)
assignin( ‘caller’, ‘cvx_problem’, cvxprob( varargin{:} ) );

Error in cluster_try_160217_1021 (line 225)

Before cvx_begin, the cvx_startup is run too (also tried with the setup, doesn’t change anything)…