== Using the free CPLEX from IBM Academic Initiative with AMPL on Windows == In order to allow AMPL to call CPLEX, an interface program called cplex.exe or cplexampl.exe is needed. If it is not provided with your version of AMPL, or if the file provided with AMPL is not compatible with your version of CPLEX, you can compile it yourself. -- How to compile cplex.exe with MS Visual C++ ? You need: * From NETLIB : the ampl/solvers directory (download from your browser by visiting ftp://www.netlib.org/ampl/solvers.tar) * From IBM : the ILOG CPLEX V12.1 optimizer (go to http://www.ibm.com/academicinitiative/ and join the Academic Intiative program, then download the installer from the Software Catalog on http://www.ibm.com/developerworks/university/software/get_software.html ; the file you need is "IBM ILOG CPLEX V12.1 for Windows English" (CZ3VBEN.exe) * From IBM : a key for ILOG CPLEX (go to http://www.ibm.com/developerworks/university/support/ilog.html and click "Request ILOG key) ; the key you obtain is file "access.ilm" * From Microsoft : the C++ compiler (download "Microsoft® Visual C++® 2008 Express Edition" version from http://www.microsoft.com/express/Downloads/#2008-Visual-CPP and install it - you can skip the optional Silverlight and SQL Server components) Step 1. Install ILOG CPLEX with CZ3VBEN.exe (use the default path - everything gets installed to C:\ILOG) Step 2. Untar the solvers.tar file in directory C:\ILOG\ (directory C:\ILOG\ampl and subdirectories are created) - you can use 7-Zip to do this Step 3. In directory "C:\ILOG\ampl\solvers", create a copy of the file "details.c0" called "details.c" Step 4. In directory "C:\ILOG\ampl\solvers\cplex", edit the file "makefile.vc": on line 54, change the CPLEXRELEASE number to 121 Step 5. Launch the Visual Studio 2008 Command Prompt and execute the following commands: CD C:\ILOG\ampl\solvers nmake makefile.vc CD cplex nmake makefile.vc Step 6. The cplex.exe interface program cplex.exe is now compiled and available in the C:\ILOG\ampl\solvers\cplex directory -- Installing and testing CPLEX with AMPL You need a working version of AMPL. Step 1. Copy the following files to the directory where AMPL is installed: cplex.exe (you may overwrite the existing nonworking file) cplex121.dll from C:\ILOG\CPLEX121\bin\x86_win32 Step 2. Copy the key file access.ilm to (new) directory C:\ILOG\ilm [alternatively you can copy it elsewhere and point the environment variable ILOG_LICENSE_FILE to the file] Step 3. Run AMPL and test CPLEX (which can be selected with the command "option solver cplex;"). For example, execute the following random knapsack problem : param n=1000; var x{1..n} binary; maximize Obj : sum {i in 1..n} Uniform01()*x[i]; subject to Cap : sum {i in 1..n} Uniform01()*x[i] <= n/4; option solver cplex; solve;