Tuesday, March 2, 2010

Installing CPLEX (educational version) on Linux

IBM recently made the full, size-unlimited version of several OR tools, including CPLEX, freely available to educators who join its Academic Initiative.  Once you've joined, you just surf to https://www.ibm.com/developerworks/university/software/get_software.html, click Download from the software catalog, sign in (if you have not already) and use the search feature to locate CPLEX (or whichever program you want).  Along with a couple of Windows installers, there's an omnibus archive file for Unix that contains 32 and  64 bit versions for several Unix and Linux distributions.  You download a license file separately from https://www.ibm.com/developerworks/university/support/ilog.html (but do not need to install the license manager program, just the license file).  They also make some courseware available.  It's a sweet deal!

Installation on Linux is pretty easy: extract the archive appropriate to your particular OS and architecture, unpack it somewhere, and park the license file someplace you can find it.  (Details are spelled out in a Quick Start guide.) That leaves the question of how you're going to run the interactive optimizer.

I decided to use a mix of two approaches on my systems, which run Linux Mint (which shares most of its plumbing with Ubuntu).  One approach was to create a run.sh file in the CPLEX installation directory.  The contents were pretty simple:

#!/bin/bash
export ILOG_LICENSE_FILE=<absolute_path_to_file>/access.ilm
<absolute_path_to_binary>/cplex

I ran chmod +x run.sh in a terminal to make it executable, then added it to Mint's main menu (mint-menu) by right-clicking the menu, selecting Edit menu, selecting an appropriate submenu, clicking New item, making the type Application in Terminal, and making the command /run.sh. Clicking this runs the interactive optimizer in a terminal window that closes automatically when I exit CPLEX.

It's also handy to be able to run the interactive optimizer from an arbitrary directory (so that I don't have to type in paths when I load files). Mint provides a convenient Open in Terminal command as part of the context menu for the file browser. (This can be added to Ubuntu by creating a shell script for it.) To make CPLEX available anywhere, in any terminal  window, I created a .bash_profile file in my home directory (since I didn't already have one) and added the following lines:

export ILOG_LICENSE_FILE=<absolute_path>/access.ilm
alias cplex=<absolute_path>/cplex

Technically I think the alias command might belong in .bashrc (which I also didn't have) rather than .bash_profile, but it works there, and why create two files if I only need one? So now I can run CPLEX's interactive optimizer in any directory.

7 comments:

  1. Turns out I ended up putting the alias and export in .bashrc after all. Just installed the academic version of CPLEX Studio 12.2 (CPLEX, OPL, CPOptimizer on Linux, same plus OPL Studio on Windows). I also bit the bullet and put the access.ilm file (a separate download) in its default location (/usr/ilog/ilm), which means I don't need to screw around exporting its location.

    ReplyDelete
  2. I did All you recomended, but when I am runing runfile it returns:"CPLEX Error 32201: ILM Error 16: CPLEX: license file not found or unreadable.
    Exiting " What's wrong? Help please.
    thanks
    kaveh

    ReplyDelete
  3. I assume that you have a valid license file installed somewhere. Run "printenv | grep ILOG" in a terminal and verify that the path it gives to the license file correctly points to the license file.

    Also, are you running the interactive optimizer, using the callable library, or running the IDE? I had to create a batch file to start the IDE. (The batch file contains the EXPORT command described above.)

    ReplyDelete
  4. I could use the interactive optimizer on Linux. But I can't find the way to run *.mod files(the example in "opl/examples/opl/" directory) What should I do?
    thanks

    Stanly
    kuokuo321@gmail.com

    ReplyDelete
  5. As of version 12.3 (possibly 12.2), the Linux distribution of CPLEX includes the OPL IDE. You should be able to run opl/oplide/oplide from a terminal. In the IDE, you can open one of the examples with File > New > Example...; click the folder of IBM examples and use the wizard's many options to find the example you want.

    If you prefer a command line version, in a terminal you can run opl/bin//oplrun. Executed without any arguments, it will give you a typical help message. You may need to preface it with 'export LD_LIBRARY_PATH=...' where ... is the path to the folder containing oplrun.

    ReplyDelete
  6. Hi, im following your answers about Opl-Cplex, and i have a question... do you know how call a csv in Linux's Opl-Cplex? Thanks

    ReplyDelete
    Replies
    1. I use CPLEX (frequently) but not OPL. You might find what you need in this thread on the developerWorks OPL/CPLEX forum: http://www.ibm.com/developerworks/forums/thread.jspa?threadID=367312.

      Delete

Due to intermittent spamming, comments are being moderated. If this is your first time commenting on the blog, please read the Ground Rules for Comments. In particular, if you want to ask an operations research-related question not relevant to this post, consider asking it on Operations Research Stack Exchange.