Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

AMPL - An Introduction

1
AMPL
 AMPL (A Mathematical Programming Language) is an algebraic
modelling language that is used for formulating and solving
optimization problems

 AMPL supports linear and non-linear programming optimization


models covering both discrete and continuous variables

 Stochastic extension of AMPL (SAMPL) supports stochastic


programming

 The user can create models and establish connection to various


data sources, such as spreadsheets, databases or plain text files,
within AMPL

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.

 AMPLDev is a graphical interface for AMPL. It is based on the


popular Eclipse development platform and is available as a stand-
alone application and as a plug-in for Eclipse.

 AMPLDev is provided by OptiRisk Systems, United Kingdom

 Some solvers supported by AMPL : CPLEX, FortMP, MINOS,


GUROBI, BARON, KNITRO, Gecode, JaCoP..

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

 Source stations = S1, S2, S3 & S4


 Destination warehouses = R1, R2, R3 & R4
 Carrying capacity of a wagon = 60 Metric Tons (MT)
 Maximum no. of wagons in a train = 58
 Cost of handling a wagon = Rs. 3600

 The set of 4 source stations is represented as:


S = {S1, S2, S3, S4}

 The set of 4 destination warehouses is represented as:

R = {R1, R2, R3, R4}

5
Data for the model (Contd.)

Warehouse Demand Storage Space Source Available Inventory


(in MT) (in MT) station (in MT)
R1 1800 11450 S1 1480
R2 1500 18938 S2 1300
R3 780 3480 S3 1760
R4 960 1200 S4 950

Rail freight cost Warehouse


(Rupees per MT) R1 R2 R3 R4
S1 1886 1886 1886 1886
Source Station

S2 1886 1886 2025 2025

S3 1747 1747 1886 1886

S4 1747 1606 1606 1466


6
-
Parameters

rcij Rail freight cost (in INR) from source station i to


warehouse j, calculated per MT
Inventory available (in MT) at source station i for
ai transportation to warehouses.

dj Demand (in MT) at destination warehouse j

sj Storage space available (in MT) at warehouse j

w max Maximum number of wagons that can be


accommodated in a train.

7
wc Carrying capacity (in MT) of a rail wagon.

rhc Cost (in INR) of handling the goods in a railway wagon.

Variables

Number of wagons allocated from the source station i


wij to warehouse j (non-negative integer)

8
Objective Function

Minimize : Total Cost =


 w
iS jR
ij  (rcij  wc  rhc)

Subject to
Constraints:

1. Availability at source station: w


jR
ij  wc  ai i  S

2. Demand constraint for warehouse :

w iS
ij  wc  d j j  R

9
3. Storage space constraint for warehouse:

w
iS
ij  wc  s j j  R

4. Limit on the maximum number of wagons in a train:

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

Taha, H., A., 2008. Operations Research: An Introduction,


Pearson Education.

Fourer, R., Gay, D. M., & Kernighan, B. W., A Modeling Language


for Mathematical Programming.
http://ampl.com/resources/the-ampl-book/chapter-
downloads/
Murarka, N., Zverovich, V., Valente, C., Valle, C., A., and Mitra, G.,
(2013). AMPLDev User Guide, OptiRisk Systems, UK.
http://www.optirisk-
systems.com/manuals/AMPLDevExtract.pdf

16

You might also like