0

I am trying to minimize a very large binary quadratic programming problem with linear constraints using the CPLEX MATLAB API. However the quadratic function f = x'Qx has a very dense matrix Q. I can rewrite Q with very sparse matrices U and A: Q = U A.

Hence, is there a way to pass these matrices to CPLEX instead of the full matrix Q (which is too large to store)?

rkersh
  • 4,447
  • 2
  • 22
  • 31
Yuki
  • 1
  • 1
  • Are you using the C Callable Library and [CPXXcopyquad](http://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.cplex.help/refcallablelibrary/qpapi/copyquad.html)? If so, that function already takes a sparse representation of the Q matrix (via qmatbeg, qmatcnt, qmatind, qmatval).... Have you tried this yet? What error are you getting? – rkersh Jun 06 '16 at 16:38
  • I am using the matlab interface. – Yuki Jun 08 '16 at 12:37

1 Answers1

0

No, this is not possible with the MATLAB API. There are two MATLAB API's: the CPLEX for MATLAB Toolbox and the Cplex class. The corresponding functions/field in each would be cplexmiqp and Cplex.Model.Q. Neither of those allow you to do exactly what you're asking for.

However (I was not previously aware of this), the MATLAB API does accept a single sparse matrix for the Q matrix (see also the MATLAB API programming tips section).

For example, these two examples are interchangeable:

cplex.Model.Q = [-33     6     0  0;
     6   -22  11.5  0;
     0  11.5   -11  0;
     0     0     0  0];

or, using a sparse matrix:

cplex.Model.Q = sparse([1, 1, 2, 2, 2, 3, 3], [1, 2, 1, 2, 3, 2, 3], [-33, 6, 6, -22, 11.5, 11.5, -11], 4, 4)

This is more explicit with the other API's (e.g., C Callable Library, C++, Python, etc.). If you are interested, the examples that are shipped with CPLEX demonstrate how that is done.

rkersh
  • 4,447
  • 2
  • 22
  • 31
  • I am not a MATLAB expert, so I was not aware of how to use native sparse matrices in MATLAB nor was I aware that CPLEX accepted them. I've made the appropriate edits to my answer. Sorry about any confusion I may have caused with that point. – rkersh Jun 09 '16 at 15:03