Initializing help system before first use

Configuring MATLAB for the Xpress Mosel interface

Please refer to the "Xpress Installation and Licensing User Guide" for instructions on Xpress installation. The MATLAB interface does not require a separate software license.

The Xpress Mosel MATLAB Interface includes a function (moselexec) to run Mosel programs, a Mosel I/O Driver to exchange data with the MATLAB environment and support for using the Java Mosel classes from MATLAB.

In order to make the new functionality available in MATLAB, the Xpress matlab directory must be added to the MATLAB search path. This can be done either using the graphical 'Set Path' dialog box or the command line. Note that this step is the same as described for the Xpress Optimizer MATLAB interface and needs to be carried only once.

For the Java Mosel classes, there are other two search paths that need to be updated: the MATLAB Java classpath and the MATLAB Java libpath.

Setting the MATLAB search path

The MATLAB search path can be set using the graphical interface as follows.

From the main MATLAB window, click on File » Set Path..., then on the 'Add Folder' button and select the matlab subfolder of your Xpress installation folder (on Windows platforms typically 'c:\xpressmp\matlab').

You should make this change permanent by clicking on the 'Save' button.

It is also possible to set the search path using the MATLAB command line, with the following instructions:

>> addpath(fullfile(getenv('XPRESSDIR'),'/matlab'))

and make this permanent with the command

>> savepath

The above command uses the XPRESSDIR environment variable to locate your Xpress installation directory; alternatively you can also specify the path directly, as in:

>> addpath 'c:\xpressmp\matlab'

(assuming you installed Xpress on 'c:\xpressmp')

Setting the MATLAB Java class path

In order to use the Java Mosel interface in MATLAB you need to add the Java Mosel library to the MATLAB Java classpath. The library consists of a Java Archive (JAR) file located under the Xpress installation directory, in the lib subdirectory. MATLAB supports both a static path and a dynamic path and you can add the Mosel JAR to either one; please refer to the MATLAB documentation, section 'Bringing Java Classes into MATLAB Workspace' for more information.

In the following, we show how to add the JAR to the static path. MATLAB loads the static path from an ASCII file named javaclasspath.txt in your preferences folder. To view the location of the preferences folder, type prefdir in MATLAB. Each line in this file is the path of a folder or a jar file. You can open this file in the MATLAB editor with the following command

>> edit(fullfile(prefdir, '/javaclasspath.txt'))

then you should add the following line to this file:

C:\xpressmp\lib\xprm.jar

(assuming you installed Xpress on 'c:\xpressmp')

Then save the file and restart MATLAB for these changes to take effect.

Alternatively, you can run the following small MATLAB script (that you can copy & paste to the MATLAB console) to automate the above operation:

fjcp = fopen(fullfile(prefdir,'/javaclasspath.txt'), 'at');
fprintf(fjcp,'\n%s\n',fullfile(getenv('XPRESSDIR'),'/lib/xprm.jar'));
fclose(fjcp);

Again, you need to restart MATLAB for these changes to take effect.

Setting the MATLAB Java library path

In order to use the Java Mosel interface in MATLAB you also need to add the Mosel native library to the MATLAB Java librarypath. The native library consists of some dynamically linked files located under the Xpress installation directory, in the bin subdirectory on Windows and in the lib subdirectory on Linux. MATLAB loads the library search path from an ASCII file named javalibrarypath.txt in your preferences folder. To view the location of the preferences folder, type prefdir in MATLAB. Each line in this file is the path of a folder. You can open this file in the MATLAB editor with the following command

>> edit(fullfile(prefdir, '/javalibrarypath.txt'))

then you should add the following line to this file:

C:\xpressmp\bin

(assuming you installed Xpress for Windows on 'c:\xpressmp')

Then save the file and restart MATLAB for these changes to take effect.

Alternatively you can run the following small MATLAB script (that you can copy & paste to the MATLAB console) to automate the above operation:

fjlp = fopen(fullfile(prefdir,'/javalibrarypath.txt'), 'at');
if isunix, libdir='/lib'; else libdir='/bin'; end
fprintf(fjlp,'\n%s\n',fullfile(getenv('XPRESSDIR'),libdir));
fclose(fjlp);

Again, you need to restart MATLAB for these changes to take effect.

Verifying if the Xpress Mosel interface works

You can verify that the Xpress Mosel MATLAB interface is working properly by executing the command

>> moselexec -v

inside MATLAB. In case everything is fine you should see something like:

XPRESS Mosel Matlab Interface function version x.x.x

Similarly, for the Java interface, the command

>> com.dashoptimization.XPRM().getVersion

should print something like:

ans =
3.5.3

© 2001-2020 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.