SPECIAL NOTE. It is imperative that the environment variable LOQODIR be set according to the instructions you received at the time of downloading loqo. If it is not, then invoking loqo from within MATLAB will result in matlab exiting with the possible loss of many hours of unsaved work. You should test the loqo executable program using an MPS or AMPL input file to make sure it is installed correctly before attempting this MATLAB interface.

First, you need to download five files:

containing gateway interface code allowing one to solve QP's using LOQO from within MATLAB.


After downloading them, type

  mex -O loqolpqp.c printf.c -I$LOQODIR $LOQODIR/libloqo.a

to create an executable that MATLAB can invoke when loqo is called from within MATLAB. Here, $LOQODIR refers to the directory where the LOQO subroutine library, libloqo.a, is located.   mex -O loqolpqp.c printf.c -largeArrayDims -I$LOQODIR $LOQODIR/libloqo.a

NOTE FOR PC USERS: On PCs, libloqo.a is called loqo.lib. The library loqo.lib was compiled using gcc under Mingw. Therefore, to make the Loqo/Matlab interface, you will need to install Mingw (go to http://www.mingw.org/ for instructions) on your machine. Then, you will need to install gnumex (go to http://gnumex.sourceforge.net/ for instructions). Once you have your matlab system set up and correctly compiling simple test programs, loqolpqp.c is compiled by putting loqo.lib into the same folder with loqolpqp.c and typing

  mex -O loqolpqp.c printf.c loqo.lib

from within Matlab at the Matlab prompt.

NOTE: If you are getting an error message saying that the function mxGetIr is obsolete, then you can compile with


Assuming the compilation is successful, to solve a problem

  Minimize c^T x + 1/2 x^T H x

  Subject to: Ax <= b
    l <= x <= u,

use the following syntax:

  [x,lambda,how] = loqolpqp(H,c,A,b,l,u,x0,neqcstr,display);

Here, H and A must be sparse matrices, x0 is an initial guess for the primal solution, neqcstr denotes the number of constraints that are in fact equality constraints (these are assumed to come first), and display is an integer indicating a level of verbosity during the solution process (default is 0, meaning no output).

The output vector x denotes the solution vector, lambda denotes the vector of dual variables (aka Lagrange multipliers), and how is a string indicating solution status (optimal, infeasible, unbounded, etc.)

Reasonable defaults are assumed for missing fields. In particular, H defaults to the sparse zero matrix (of appropriate dimension), l defaults to the minus-infinity vector, and u defaults to the infinity vector. Hence, to use loqolpqp() to solve a linear programming problem with free variables, producing verbose output, and only returning the primal solution vector, one would type

  x = loqolpqp([],c,A,b,[],[],[],[],2);

Give it a try. Comments welcome.