Setting up CPLEX for Academics with Eclipse on Linux

This is the description on how to set up IBM ILOG CPLEX Optimization Studio for Academics (link here), so it can be used under Eclipse in Linux environment.

0. What we need before we start:

  • a membership in IBM Academic Initiative (join or renew here)
  • Eclipse installed
  • Linux system (in this case it was done on Ubuntu 12.04.)

1. Download an installer

Go to: https://www.ibm.com/developerworks/university/software/get_software.html

Click on Download from the Software Catalog, log in if necessary

Search for cplex

Choose the Linux option you need, e.g.: IBM ILOG CPLEX Optimization Studio V12.4 for Linux x86-64 Multilingual.

Save the downloaded file cplex_studio124.linux-x86-64.bin on you disk to some directory.

2. Install CPLEX

Change the file permission on downloaded file cplex_studio124.linux-x86-64.bin, so the installation can be executed and run the installer.

In directory containing installer:

chmod +x cplex_studio124.linux-x86-64.bin
sudo ./cplex_studio124.linux-x86-64.bin

This will by default install CPLEX in /opt/ibm/ILOG/CPLEX_Studio124/

The license file access.ilm is not required in this CPLEX version.

3. Add CPLEX jar library to the project

If your are using maven add following lines to dependencies for your project:


<dependency>
<groupId>cplex</groupId>
<artifactId>cplex</artifactId>
<version>12.4</version>
</dependency>

And install the cplex.jar in your maven repository:

mvn install:install-file -DgroupId=cplex -DartifactId=cplex -Dversion=12.4 -Dpackaging=jar -Dfile=/opt/ibm/ILOG/CPLEX_Studio124/cplex/lib/cplex.jar

If you don’t have installed m2eclipse Eclipse maven plugin, then run also:

mvn eclipse:eclipse

If you don’t use maven look into this guidelines: Configuring the Eclipse Java IDE to use CPLEX libraries

4. Add path to native library

To run your project using CPLEX library in Eclipse add this line:

-Djava.library.path=/opt/ibm/ILOG/CPLEX_Studio124/cplex/bin/x86-64_sles10_4.1

to Run Configurations for your project under Arguments in VM Arguments section. The last part x86-64_sles10_4.1 can differ. Anyway, this should point to directory, where CPLEX native files are located, that is those that end up with .so and cplex binary.

This is necessary to avoid this kind of exception:

java.lang.UnsatisfiedLinkError: no cplex124 in java.library.path
java.library.path must point to the directory containing the CPLEX shared library
try invoking java with java -Djava.library.path=...
Exception in thread "main" java.lang.UnsatisfiedLinkError: ilog.cplex.Cplex.CPXopenCPLEX([I)J
at ilog.cplex.Cplex.CPXopenCPLEX(Native Method)
at ilog.cplex.CplexI.init(CplexI.java:5722)
at ilog.cplex.CplexI.(CplexI.java:611)
at ilog.cplex.IloCplex.(IloCplex.java:10384)

Summary

After completing all above steps you should be able to use CPLEX classes in your project in Eclipse.

This entry was posted in Uncategorized. Bookmark the permalink.

1 Response to Setting up CPLEX for Academics with Eclipse on Linux

  1. tgrez says:

    Properly setting a MIP start in Java API:
    IloNumVar[] startVar = new IloNumVar[m * n];
    double[] startVal = new double[m * n];
    for (int i = 0, idx = 0; i < m; ++i)
    for (int j = 0; j < n; ++j) {
    startVar[idx] = x[i][j];
    startVal[idx] = start[i][j];
    ++idx;
    }
    cplex.addMIPStart(startVar, startVal);
    startVar = null;
    startVal = null;

    taken from: http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r3/index.jsp?topic=%2Filog.odms.cplex.help%2FContent%2FOptimization%2FDocumentation%2FOptimization_Studio%2F_pubskel%2Fps_usrmancplex1850.html

Leave a comment