3. Installation


In order to use the MOSEK optimization toolbox for MATLAB, you must install the MOSEK optimization tools. Please see chapter 2. in The MOSEK installation manual for details.

http://www.mosek.com/fileadmin/products/5%5f0/tools/doc/html/toolsinstall/node003.html

3.1. Locating the toolbox functions

By default MATLAB cannot locate the MOSEK optimization toolbox functions. Therefore you must execute the addpath command within MATLAB to change the so-called matlabpath appropriately. Indeed matlabpath should include a path to the MOSEK optimization toolbox functions. The next subsections shows how to use addpath.

3.1.1. On Windows

% If you use MATLAB 7.4 (R2007a) or any later version do
addpath 'c:\Program Files\mosek\5\toolbox\r2007a'

% For  MATLAB 7.3 (R2006b)
addpath 'c:\Program Files\mosek\5\toolbox\r2006b'

% For  MATLAB 7.2 (R2006a)
addpath 'c:\Program Files\mosek\5\toolbox\r2006a' 

This assumes you installed MOSEK at

c:\Program Files\

If that is not the case, then you will have to change the path given to addpath.

3.1.2. On Linux/UNIX/MAC OSX

If you are using UNIX or a UNIX like operating system you should do

% For MATLAB 7.4 (R2007a) or any later version  do
addpath '/home/user/mosek/5/toolbox/r2007a'

% For MATLAB 7.3 (R2006b)
addpath '/home/user/mosek/5/toolbox/r2006b'

% For MATLAB 7.2 (R2006a)
addpath '/home/user/mosek/5/toolbox/r2006a'

This assumes MOSEK is installed at

/home/user

3.1.3. Permanently changing matlabpath

Normally you will have to do addpath command every time MATLAB is started. However, it can be avoided if the addpath command is added to the file

<matlab>toolbox\local\startup.m

where <matlab> is the MATLAB root directory. Alternatively the permanent modification of the MATLAB path can be performed using the menu item

\File\Set Path

3.2. Verifying MOSEK works

You can verify that MOSEK works by executing the command

mosekopt

inside MATLAB. In case MOSEK you should get something like

MOSEK Version 3.1.1.62 (Build date: Dec 16 2004 11:49:51)
Copyright (c) 1998-2004 MOSEK ApS, Denmark. WWW: http://www.mosek.com


    MOSEK command summary.

        [r,res]=mosekopt(cmd,prob,param,log)

If you do not get that, then please read Section 3.3.

3.3. Troubleshooting

3.3.1. ??? Undefined function or variable 'mosekopt'

In the case you get the MATLAB error message

??? Undefined function or variable 'mosekopt'

you have not setup the matlabpath correctly as described in Section 3.1.

3.3.1.1. Unable to load mex file

One reason can be you are not adding the correct path to the matlabpath. For instance you may be trying to use the MOSEK optimization toolbox build for MATLAB 7 in MATLAB 6.

The other possible reason is discussed below.

  • Windows:

    MATLAB reports something like

    DLL load failed for mex file
    c:\mosek\3\tools\toolbox\14sp3\mosekopt.dll The
    specified procedure could not be found. ??? Invalid MEX-file
    

    This problem is most likely caused by MOSEK cannot load the MOSEK DLL which in turn is caused by the operating system variable

    PATH
    

    is not appropriately setup.

    Please consult the “MOSEK optimization tools installation manual” and read about how to install MOSEK under Windows and how to setup the operating system variable PATH.

  • MAC OSX:

    The problem is that operating system variable DYLD_LIBRARY_PATH variable is not appropriately setup. Setting this variable can be tricky. In particularly if you are invoking MATLAB by clicking on the MATLAB icon. In this case a file named

    $HOME/.MacOSX/environment.plist
    

    with a proper content should exists on your computer. Further details about the file environment.plist and how to install MOSEK under MAC OSX can be seen in the “MOSEK optimization tools installation manual”.

  • UNIX:

    MATLAB reports something like

    Unable to load mex file:
    /usr/local/mosek/4/toolbox/14sp3/mosekopt.mexglx.
    libmosek.so.2.5: cannot open shared object file: No such file or
    directory ??? Invalid MEX-file
    

    The cause of the problem is that the shared library

    libmosek.so.2.5
    

    cannot be loaded. This problem normally is caused by that the OS environment variable

    LD_LIBRARY_PATH
    

    is not appropriately setup. Observe that LD_LIBRARY_PATH may have another name on some UNIX systems. Please consult the “MOSEK optimization tools installation manual” and read about how to install MOSEK under UNIX.

3.3.2. libgcc_s.so.1 must be installed for pthread_cancel to work

This error is caused by an old version of the library

libgcc_s.so.1

is included in the MATLAB distribution. One method of solving this is to execute the command

export  LD_PRELOAD=/usr/lib/libgcc_s.so

before running MATLAB.

Another workaround is to remove libgcc_s.so.1 in the MATLAB distribution. We suggest you rename the file

<matlab>sys/os/glnx86/libgcc_s.so.1

to

<matlab>sys/os/glnx86/BACKUP_libgcc_s.so.1.bak

and the problem should be solved.

3.3.3. Compiling with the MATLAB compiler

MATLAB scripts using MOSEK can be compiled with the MATLAB compiler. Below is a description of some possible errors and their solution.

3.3.4. Shadows the M-file

If you encounter the error

The file
  '/tools/mosek/4/toolbox/r14sp3/mosekopt.mexglx'
appears to be a MEX-file. It shadows the M-file
'/tools/mosek/4/toolbox/r14sp3/mosekopt.m'
but will not execute properly at runtime, as it does not export a function
named 'mexFunction.'
??? Error executing mcc, return status = 1.

when compiling a MATLAB script using MOSEK then you must delete the file

c:\mosek\5\toolbox\<MATLABVERSION>\mosekopt.m

This should fix the compile error.

3.3.5. Cannot find authentication file

If you encounter the error

Cannot find authentication file
'C:\mosek\4\toolbox\r2006b\mosekopt_mexw32.auth'
.

??? Invalid MEX-file 'C:\mosek\4\toolbox\r2006b\mosekopt.mexw32': .

The try removing any addpath commands from your code when compiling. Instead, specify the location of the MOSEK files with

-I  c:\mosek\4\toolbox\r2006b

in the compile command.

Mon Sep 14 15:56:06 2009