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;


2) ampl: model myprog.mod;

ampl:option solver gurobi;


3) ampl: model myprog.mod;


4) ampl: model myprog.mod;

ampl:option solver lpSolve;


5) ampl: model myprog.mod;

ampl:option solver snopt;


No comments:

Post a Comment