Professional Documents
Culture Documents
AMPL Introduction
AMPL Introduction
1
AMPL
AMPL (A Mathematical Programming Language) is an algebraic
modelling language that is used for formulating and solving
optimization problems
2
AMPL
From the model and data, the AMPL translator generates an
internal representation, passes it to one of the many solvers
supported by AMPL and provides the user with the results.
3
Problem
There are 4 factories (S1, S2, S3 and S4) producing
product P. The product is to be transported to 4
warehouses (R1, R2, R3 and R4) using rail wagons. The
carrying capacity of a wagon and the maximum number of
wagons that can be accommodated in a train is limited.
The available inventory at each source station (factory)
and the demand and storage space at each destination
warehouse are also provided. Further, a fixed handling
cost is incurred for loading and unloading the wagons.
Determine the transportation plan that incur the
minimum transportation cost.
4
Data for the model
5
Data for the model (Contd.)
7
wc Carrying capacity (in MT) of a rail wagon.
Variables
8
Objective Function
Subject to
Constraints:
w iS
ij wc d j j R
9
3. Storage space constraint for warehouse:
w
iS
ij wc s j j R
wij w max i S , j R
10
Reddy Mikks problem
11
Reddy Mikks problem (Contd.)
12
Model Formulation
13
Model formulation (Contd.)
n2
m
j 1
kj x j marketk k
14
AMPL MODEL
set products; data;
set resource;
set restriction; set products:= EP IP;
set resource:= M1 M2;
param C {products}; set restriction:= MAT MKT;
param mat {resource};
param market {restriction}; param: C:= EP 5 IP 4;
param a {resource, products}; param: market:= MAT 1 MKT 2;
param m {restriction, products}; param: mat:= M1 24 M2 6;
param a: EP IP:=
var x {products}; M1 6 4
M2 1 2;
maximize Profit: sum {j in products} param m: EP IP:=
C[j]*x[j]; MAT -1 1
MKT 0 1;
subject to material_constraint {i in
resource}: sum {j in products} option solver CPLEX;
a[i,j]*x[j] <= mat[i]; solve;
display _solve_time;
subject to marketing_constraint {i in display x;
restriction}: sum {j in products} display Profit;
m[i,j]*x[j] <= market[i]; display x.lb, x, x.ub, x.rc,
x.slack;
subject to non_negativity_constraint{i
in products}: x[i]>=0;
15
References
16