Affichage des articles dont le libellé est cplex. Afficher tous les articles
Affichage des articles dont le libellé est cplex. Afficher tous les articles

lundi 14 mars 2011

how to install cplex on unix-based machine

========================
first of all, you have to get
    - the distribution cplex122.x86linux.tar.gz and
    - an authentication file: access_122.ilm.

then, extract the cplex122.x86linux.tar.gz to any path you wish on your computer's disk.

next, set up an environment variable: ILOG_LICENSE_FILE which point to the access_122.ilm file.

up to now, the compiler is installed, you will have the following file structure:

    - <cplex_installed_path>
        - concert27
        - cplex122

to verify the installation:
    - go to <cplex_installed_path>/cplex122/bin/x86_darwin8_gcc4.0/ in the terminal;
    - run ./cplex to start the interactive optimizer.

if you can see the following screen, it means the cplex is well installed:

ILOG CPLEX 11.210, licensed to "inria-grenoble", options: e m b q use=10 MaintenanceEnd=20110330

Welcome to CPLEX Interactive Optimizer 11.2.1
  with Simplex, Mixed Integer & Barrier Optimizers
Copyright (c) ILOG 1997-2008
CPLEX is a registered trademark of ILOG

Type 'help' for a list of available commands.
Type 'help' followed by a command name for more
information on commands.

CPLEX>


===================

how to use cplex with Java

to compile a Java program which calls the cplex:

  javac -classpath /Users/cwang/Documents/workspace/cplex/cplex112.x86_mac/cplex112/lib/cplex.jar:.(pay attention to include the current directory by using :.)

and to execute:

  java -Djava.library.path=/Users/cwang/Documents/workspace/cplex/cplex112.x86_mac/cplex112/bin/x86_darwin8_gcc4.0/libcplex112.so -classpath /Users/cwang/Documents/workspace/cplex/cplex112.x86_mac/cplex112/lib/cplex.jar:. Diet

where the Diet is the name of the program.

Configuring the Eclipse Java IDE to use CPLEX libraries

Question

How do I configure the Eclipse Java IDE to use CPLEX libraries?

Cause

To specify the configuration details required to connect the Eclipse Java IDE with CPLEX libraries.

Answer

Perform the following steps to configure Eclipse with CPLEX:
1. If you are creating a new Java project
File -> New -> Java project
Else, import the existing project into your workspace
File -> Import -> Expand on 'General' -> Select 'Existing Projects into Workspace'

2. Create source (class) files as needed. To add a new class to the project,
Right click on the source folder (src) -> New -> Class, specify a name, change the
properties like package, modifiers, automatic stubs etc as required, and then click 'Finish'.
To add an existing java file to the project, simply drag and drop the .java file into the 'src'
folder of the project. Sample java programs can be found under <cplex>\examples\src\java
directory.

3. Include the CPLEX jar in the project
a) Project -> Properties -> Java Build Path -> Libraries tab ->
b) Click the 'Add External JARs ...' button and point to cplex.jar
file (found under the <CPLEX>/lib directory)

4. Run Configuration setup
a) Run -> Run Configurations ... -> Java Application
b) Right click to select 'New' if no Run Configuration exists or select the one
which you would like to configure.
c) On the 'Main' tab select your main class (the class containing
the main() function that you want to run).
d) On the 'Arguments' tab add the following to 'VM arguments' section
-Djava.library.path=<path_to_so_or_dll>
where <path_to_so_or_dll> is the directory that contains the
libcplex<version>.so (Linux) or cplex<version>.dll (Windows) file found
by default under the <CPLEX_installation_dir>/bin/<port> directory.
e) If the PATH environment variable is globally defined and includes CPLEX's
.dll or .so (platform dependant) files, then the previous step is not required.
f) This step is required only if you are using CPLEX 12.1 or an earlier version.
If CPLEX's license path is not globally defined under the ILOG_LICENSE_FILE
environment variable, then you can do so in the 'Environment' tab. Click 'New'
and enter ILOG_LICENSE_FILE as the Name and <license_file_location> as the
Value. The <license_file_location> needs to specify the license file name as well and not
just the directory it is present under.

5. You should now be able to run the program.

original link: http://www-01.ibm.com/support/docview.wss?uid=swg21449776