Department of Mathematics FAS Harvard University One Oxford Street Cambridge MA 02138 USA Tel: (617) 495-2171 Fax: (617) 495-5132
FAS Computer Services to Harvard University IT: (617) 495-7777.
AMPL is a an algebraic modeling language for linear and nonlinear optimization problems, in discrete or continuous variables. It allows to solve and analyze optimization problems with up to 300 variables and constraints.

Developed at Bell Laboratories, AMPL lets you use common notation and familiar concepts to formulate optimization models and examine solutions, while the computer manages communication with an appropriate solver like CPLEX.

AMPL's flexibility and convenience render it ideal for rapid prototyping and model development, while its speed and control options make it an especially efficient choice for repeated production runs.

Getting the programs

  • You can download a student edition of ampl for Solaris, OS X or linux here.
  • You need also a "solver" like "cplex".
  • Examples of AMPL files can be found on this page

Example

Assume, you have steel3.dat, steel3.mod and steel3.run which contains the ampl commands, you can run it from the commandline as


  ampl < steel3.run 
It will give you the optimal solution 194828.5714 which is the maximal total profits from all products. It uses the constraint total of hours used by all products may not exceed the available hours.


file steel3.dat file steel3.mod file steel3.run
set PROD := bands coils plate;

param:    rate  profit  commit  market :=
  bands    200    25     1000    6000
  coils    140    30      500    4000
  plate    160    29      750    3500 ;

param avail := 40;
set PROD;
param rate {PROD} > 0; 
param avail >= 0;  
param profit {PROD}; 
param commit {PROD} >= 0; 
param market {PROD} >= 0; 
var Make {p in PROD} >= commit[p], <= market[p];
maximize total_profit: sum {p in PROD} profit[p] * Make[p];
subject to Time:  sum {p in PROD} (1/rate[p]) * Make[p] <= avail;
model steel3.mod;
data  steel3.dat;
option solver cplex;
solve;
exit; 


Simplicity, Clarity, Generality B.W. Kernighan, R. Pike, in "The Practice of Programming".
Privacy
HTML CSS