Feb 27, 2013

AMPL optimization tool on Mac OS


AMPL is a mathematical programming language. It can be downloaded from http://www.ampl.com/DOWNLOADS/index.html. There are some useful solvers as well. http://www.ampl.com/DOWNLOADS/details.html. Most of them require student ident.

After you download or install AMPL and those solvers, you need to use command "chmod +x ..." to convert them to executable program on Mac.

Then, you must edit environment variables (in ~/.bashrc file) to add ampl and related libraries/licenses.

export PATH=...:/your/AMPL/path/ampl

export DYLD_LIBRARY_PATH=/your/knitro/path/lib

export ZIENA_LICENSE=/your/knitro/license/path

For the testing of AMPL, we create a file named as myprog.mod and write a simple model,

var XB;

var XC;

maximize Profit: 25 * XB + 30 * XC;

subject to Time: (1/200) * XB + (1/140) * XC <= 40;

subject to B_limit: 0 <= XB <= 6000;

subject to C_limit: 0 <= XC <= 4000;


Then, change directory to the myprog.mod file. type ampl on the command prompt and we can try to solve it by different solvers. (the default solver of AMPL is MINOS)

1) ampl: model myprog.mod;

ampl:option solver knitroample;

ampl:solve;

2) ampl: model myprog.mod;

ampl:option solver gurobi;

ampl:solve;

3) ampl: model myprog.mod;

ampl:solve;

4) ampl: model myprog.mod;

ampl:option solver lpSolve;

ampl:solve;

5) ampl: model myprog.mod;

ampl:option solver snopt;

ampl:solve;


Feb 22, 2013

Download and install IBM Cplex solver (Academic version) for your AMPL


By default, AMPL uses MINOS as an optimization solver. However, Cplex which was developed by IBM is the most useful solver. The official website of IBM is not so friendly and they do not remove some web pages which are out of date.

To download Cplex, you have to register a academic membership at first.

1) Go to http://www-03.ibm.com/ibm/university/academic/pub/page/software and find the link "Join now - at no charge"(if the first time) or "Renew your membership"

2) Then, step 1: you will be asked to Register for a universal IBM ID and password (use your academic email address to do it). step 2: Complete the Academic Initiative program membership process (click "apply as a faculty member"). http://www-03.ibm.com/ibm/university/academic/pub/page/mem_join

3) After that, you will receive a confirmation email saying the application has been approved.

4) Visit the page http://www-03.ibm.com/ibm/university/academic/pub/page/sof_all_software, and click the link where is at bottom Search the Academic Initiative Software Download Catalog (This is pretty tricky)

5) After submitting your request, you will go to "IBM Academic Initiative Software Downloads" page.

6) Type "cplex" on "Find by search text" and you will see a list of cplex version choose one and you will see the software list.

7) Since the download needs java applet, you have to enable it for your browser.


8) After the download is finished, you will have a .bin file like "cplex_studio125.macos.bin"(here I download cplex12.5). DO NOT put it to your Application folder as it is not an application which can be run by your Mac.

9) Put it to some other directory. Open a terminal and find that directory. This bin file is a shell script, so you have to run it by bash. type and run this command 
"/bin/bash ~/your/path/cplex_studio125.macos.bin"

10) Follow the instruction and you will install it successfully.

11) Finally, do not forget configure the environment variable for the license: export  ILOG_LICENSE_FILE=/your/license/path/access.lim

12) The access.lim is generated from your IBM Academic Initiative.