From Documentation
Jump to: navigation, search
Note: Some of the information on this page is for our legacy systems only. The page is scheduled for an update to make it applicable to Graham.
ILOGCPLEX
Description: A component of IBM ILOG CPLEX Optimization Studio
SHARCNET Package information: see ILOGCPLEX software page in web portal
Full list of SHARCNET supported software


Introduction

Users must join first the ilogcplex group before the software will be usable. Ilogcplex can be used in the queue for running compute intensive jobs or interactively by running the oplide command as described in the General Notes section below.

Version Selection

module load ilogcplex/12.4

Job Submission

Either serial or threaded ilogcplex jobs can be run in the queue as described in the following example job section.

Example Job

The section shows howto conduct cplex scaling timing tests in serial and paralle. The example described at the bottom of the sourceforge CPLEX LP file format document will be used. Save it into your current working directory as a simple text file named testcplex.lp as shown here:

[roberpj@orca:~/samples/ilogcplex] cat testcplex.lp
NAME testcplex.lp
Maximize
 obj: x1 + 2 x2 + 3 x3 + x4
Subject To
 c1: - x1 + x2 + x3 + 10 x4 <= 20
 c2: x1 - 3 x2 + x3 <= 30
 c3: x2 - 3.5 x4 = 0
Bounds
 0 <= x1 <= 40
 2 <= x4 <= 3
General
 x4
End

Conducting Scaling Tests in the Queue

First create batch run scripts required to submit jobs to the the serial queue (using 1cpu) or the threaded queue (using 4cpu or 8cpu) as shown here:

[roberpj@orca:~/samples/ilogcplex] cat run1cpu.inp
read test1cpu.lp
set threads 1
optimize
display solution variables x1-x3
quit

[roberpj@orca:~/samples/ilogcplex] cat run4cpu.inp
read test1cpu.lp
set threads 4
optimize
display solution variables x1-x3
quit

[roberpj@orca:~/samples/ilogcplex] cat run8cpu.inp
read test1cpu.lp
set threads 8
optimize
display solution variables x1-x3
quit

o Next submit three test jobs to the queue as follows:

[roberpj@orca:~/samples/ilogcplex] sqsub -t -r 5m -q serial -o ofile%J -i run1cpu.inp cplex
submitted as jobid 61496

[roberpj@orca:~/samples/ilogcplex] sqsub -t -r 5m -q threaded -n 4 -o ofile%J -i run4cpu.inp cplex
submitted as jobid 61497

[roberpj@orca:~/samples/ilogcplex] sqsub -t -r 5m -q threaded -n 8 -o ofile%J -i run8cpu.inp cplex
submitted as jobid 61498

o The timing results show for this case 4cpu provides the fastest solution time:

[roberpj@orca:~/samples/ilogcplex] cat ofile61496 | grep Elapsed
Elapsed real time =   0.21 sec. (tree size =  0.00 MB, solutions = 2)

[roberpj@orca:~/samples/ilogcplex] cat ofile61497 | grep Elapsed
Elapsed real time =   0.04 sec. (tree size =  0.00 MB, solutions = 3)

[roberpj@orca:~/samples/ilogcplex] cat ofile61498 | grep Elapsed
Elapsed real time =   0.22 sec. (tree size =  0.00 MB, solutions = 3)

Conducting Scaling Tests Interactively

Similar to the previous queue approach the set threads parameter must be set. Failure to do so will result in your interactive job using all available cores. To conduct the test we recommend logging into a development node (for instance orc-dev1) instead of using a login node to obtain more reliable results since login nodes are heavily used. For instance to run the 4core test simply do the following:

ssh orca.sharcnet.ca
ssh orc-dev1
module load ilogcplex
cplex
CPLEX> set threads 8
CPLEX> read  testcplex.lp
CPLEX> optimize
Parallel mode: deterministic, using up to 8 threads.
etc
CPLEX> quit

One could also utilize the aforementioned 8cpu input scripote: bt run8cpu.inp to run the jobs for example:

ssh orca.sharcnet.ca
ssh orc-dev1
module load ilogcplex
cplex < run8cpu.inp >& run8cpu.out

Based on further limited testing, setting OMP_NUM_THREADS or CPX_PARAM_THREAD doesnt appear to control the number of threads and therefore setting either variable will result in all cores being used, unless "set threads #" is specified.

General Notes

Using The Studio via the IDE GUI

Oplide can be run on the iqaluk smp machine by connecting directly with xming from a windows machine. Or if connecting from linux or mac more simply use ssh as follows:

[roberpj@mylinuxlaptop:~] ssh -Y iqaluk.sharcnet.ca
[roberpj@iqaluk:~] module load ilogcplex
[roberpj@iqaluk:~] oplide

On orca and saw the oplide command can only be run by first tunneling into one of the devel nodes (such as orc-dev1 or saw-dev1) from the login node then reloading the ilogcplex module. For instance:

[roberpj@mylinuxlaptop:~] ssh -Y orca.sharcnet.ca  (use xming if connecting from a windows laptop)
[roberpj@orc-login2:~] ssh -Y orc-dev1
[roberpj@orc129:~] module load ilogcplex
[roberpj@orc129:~] oplide

Otherwise, attempting to start oplide directly on a login node will result in an error message such libgcc_s.so.1 must be installed for pthread_cancel to work.

Compiling C/C++ Programs with Cplex

o C programs such as /opt/sharcnet/ilogcplex/12.2/cplex/examples/src/c/qpex1.c can be compiled by doing:

[roberpj@orca:~/samples/ilogcplex] gcc qpex1.c -o qpex1.o -c -fPIC $CPPFLAGS
[roberpj@orca:~/samples/ilogcplex] gcc qpex1.o -o qpex1 -fPIC $CPPFLAGS $LDFLAGS -lcplex -lm -lpthread

o C++ programs such as /opt/sharcnet/ilogcplex/12.2/cplex/examples/src/cpp/ilolpex1.cpp can be compiled as follows:

[roberpj@orca:~/samples/ilogcplex] g++ ilolpex1.cpp -o ilolpex1.o -c -O -fPIC -fexceptions -DNDEBUG -DIL_STD $CPPFLAGS
[roberpj@orca:~/samples/ilogcplex] g++ ilolpex1.o -o ilolpex1 -O -fPIC -fexceptions -DNDEBUG -DIL_STD -DILOSTRICTPOD $CPPFLAGS $LDFLAGS -lilocplex -lcplex -lconcert -lm -lpthread


o The C binary generated can be run in the serial queue with corresponding output shown:

[roberpj@orca:~/samples/ilogcplex] sqsub -t -r 5m -q serial -o ofile%J ./qpex1
submitted as jobid 61505

[roberpj@orca:~/samples/ilogcplex] cat ofile61505
IBM ILOG License Manager: "IBM ILOG Optimization Suite for Academic Initiative" is accessing CPLEX 12 with option(s): "e m b q ".
Number of nonzeros in lower triangle of Q = 2
Using Approximate Minimum Degree ordering
Total time for automatic ordering = 0.00 sec.
Summary statistics for factor of Q:
  Rows in Factor            = 3
  Integer space required    = 3
  Total non-zeros in factor = 6
  Total FP ops to factor    = 14
Tried aggregator 1 time.
Reduced QP has 5 rows, 6 columns, and 14 nonzeros.
Reduced QP objective Q matrix has 3 nonzeros.
Presolve time =    0.06 sec.
Parallel mode: using up to 127 threads for barrier.
Number of nonzeros in lower triangle of A*A' = 9
Using Approximate Minimum Degree ordering
Total time for automatic ordering = 0.00 sec.
Summary statistics for Cholesky factor:
  Threads                   = 127
  Rows in Factor            = 5
  Integer space required    = 5
  Total non-zeros in factor = 15
  Total FP ops to factor    = 55
 Itn      Primal Obj        Dual Obj  Prim Inf Upper Inf  Dual Inf          
   0   1.0636929e+02   4.0119631e+04  3.00e+02  2.20e+01  4.02e+03
   1  -4.2647339e+03   1.3830857e+04  8.95e+00  6.58e-01  1.20e+02
   2  -5.7244038e+02   2.1778053e+03  8.88e-15  0.00e+00  1.57e-13
   3  -1.3359320e+02   2.1366540e+02  2.49e-14  0.00e+00  4.88e-14
   4  -1.5446636e+01   4.4803921e+01  8.44e-15  0.00e+00  8.38e-15
   5   3.4390904e-01   7.1112812e+00  6.88e-15  0.00e+00  1.43e-15
   6   1.9389541e+00   2.6972949e+00  9.88e-15  0.00e+00  1.44e-15
   7   2.0140768e+00   2.1563147e+00  1.12e-14  0.00e+00  1.61e-15
   8   2.0155916e+00   2.0388811e+00  4.11e-15  7.11e-15  6.47e-16
   9   2.0156158e+00   2.0194824e+00  4.00e-15  7.11e-15  6.45e-16
  10   2.0156165e+00   2.0162605e+00  1.18e-14  7.11e-15  5.98e-16
  11   2.0156165e+00   2.0157238e+00  5.00e-15  0.00e+00  1.84e-15
  12   2.0156165e+00   2.0156344e+00  7.66e-15  0.00e+00  1.51e-15
  13   2.0156165e+00   2.0156195e+00  7.44e-15  7.11e-15  1.81e-15
  14   2.0156165e+00   2.0156170e+00  8.10e-15  7.11e-15  1.10e-15
  15   2.0156165e+00   2.0156166e+00  1.09e-14  0.00e+00  1.30e-15
  16   2.0156165e+00   2.0156165e+00  1.48e-14  7.11e-15  1.79e-15

Total real time on 127 threads =    0.20 sec.

Solution status = 1
Solution value  = 2.015617

Row 0:  Slack =  18.642254  Pi =   0.000000
Row 1:  Slack =  30.757886  Pi =   0.000000
Column 0:  Value =   0.139115  Reduced cost =  -0.000000
Column 1:  Value =   0.598465  Reduced cost =  -0.000000
Column 2:  Value =   0.898396  Reduced cost =  -0.000000
Default variable names x1, x2 ... being created.
Default row names c1, c2 ... being created.

References

o IBM ILOG CPLEX Optimization Studio - Online Documentation
http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r4/index.jsp?topic=/ilog.odms.cplex.help

o IBM ILOG CPLEX Optimization Studio - Getting Started with CPLEX
http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r4/topic/ilog.odms.studio.help/pdf/gscplex.pdf

o IBM ILOG CPLEX Optimization Studio - Support
http://www-947.ibm.com/support/entry/portal/Overview/Software/WebSphere/IBM_ILOG_CPLEX_Optimization_Studio