Mathematical Programming: Modelling and Applications October 2009 - - PowerPoint PPT Presentation
Mathematical Programming: Modelling and Applications October 2009 - - PowerPoint PPT Presentation
Mathematical Programming: Modelling and Applications October 2009 Sonia Cafieri LIX, cole Polytechnique cafieri@lix.polytechnique.fr Outline A modelling problem: Carelland Formulation of the mathematical model The AMPL model
2
Outline
A modelling problem: Carelland Formulation of the mathematical model The AMPL model Solution Another modelling problem: Dyeing Formulation of the mathematical model The AMPL model Solution
3
Carelland problem
The independent state of Carelland mainly exports four goods: steel, engines, electronic components and plastics. We want to maximize exports and minimize imports. The unit prices on the world markets for the 4 products are given. For each product it is also known:
- the number of unities of the other 3 products,
- the price of other imported goods,
- the man-months of work
needed to produce 1 unit of product. Furthermore: There is a maximum possible production for electronics and plastic materials. The total available workforce for each year is known. Steel, engines, electronics and plastics cannot be imported. Write a mathematical program that maximizes the gross internal product and solve the problem with AMPL.
4
Carelland: data
Producing 1 steel unit requires: 0.02 engine units, 0.01 plastics units, 250$ in imported goods and 6 man- months of work. Producing 1 engine unit requires: 0.8 steel units, 0.15 electronics units, 0.11 plastics units, 300$ in imported goods and 1 man-year. Producing 1 electronics unit requires: 0.01 steel units, 0.01 engine units, 0.05 plastics units, 50$ in imported goods and 6 man-months. Producing 1 plastics unit requires: 0.2 steel units, 0.03 engine units, 0.05 electronics units, 300$ in imported goods and 2 man-years.
5
Carelland: data
Unit prices on the world markets :
steel 500 engines 1500 electronics 300 plastics 1200
Maximum possible production: Total available workforce: 830000 man-year.
steel
- engines
- electronics
650000 plastics 60000
6
Writing the mathematical model
- Objective function
What do we have to maximize? Note: the profits can be expressed in terms of exported quantities and produced quantities.
- Variables
What do we have to decide? Note : we have a certain number of goods and, for each of them, an amount of produced and exported units.
- Parameters and Sets
Consider a set containing the products. What are the parameters?
7
Writing the mathematical model
- Constraints
- 1. The amount of work needed to produce all the products (man-months)
cannot exceed the total available workforce per year.
- 2. There is a maximum possible production for some of the products.
Note: this limit is not imposed on all products. How can this condition be expressed?
- 3. For each product, the produced quantity must balance the exported
quantity and the quantity needed to produce the other products. Suggestion: start writing, for each product, the relation among the total produced quantity, the exported quantity, the quantity needed for each
- ther product. Then, try to write these constraints in a more compact
form.
8
Mathematical model
- Parameters and Sets
P = {a,m,e,p}: set of products (a = steel, m = engines, e = electronic, p = plastic) H: total available amount of work (man-years) Mi : maximum possible production for product i∈P hi : amount of work required to manufacture a unit of product i∈P mi : price of raw materials necessary to manufacture a unit of product i∈P pi : market price for product i∈P
- Variables
xa , xm , xe , xp : produced units of steel, engines, electronics and plastics ya , ym , ye , yp : exported units of steel, engines, electronics and plastics
All variables are non negative
9
Mathematical model
- Objective function
∑ ∑
∈ ∈
−
P i i i i P i i
x m y p max
maximize the profits profits: exported quantities minus produced quantities
05 . 11 . 01 . 05 . 15 . 03 . 01 . 02 . 2 . 01 . 8 .
e m a p p p m e e p e a m m p e m a a i i P i i i
x x x y x x x y x x x x y x x x x y x M x P i H x h + + + = + + = + + + = + + + = ≤ ∈ ∀ ≤
∑
∈
- Constraints
- amount of work:
- maximum production:
- balance:
10
Mathematical model
05 . 11 . 01 . 05 . 15 . 03 . 01 . 02 . 2 . 01 . 8 .
e m a p p p m e e p e a m m p e m a a
x x x y x x x y x x x x y x x x x y x + + + = + + = + + + = + + + =
can be written as:
∑
∈
+ = ∈ ∀
P j j ji i i
x a y x P i
where: Note that the following constraints
⎪ ⎩ ⎪ ⎨ ⎧ = = ∈ ∀
- therwise
product
- f
unit 1 produce to needed product
- f
units if , j i j i a P j i
ij
11
AMPL model – Carelland
set PRODUCTS; param p {PRODUCTS} >= 0; param HMan >=0; param Max {PRODUCTS} >=0; param m {PRODUCTS} >= 0; param h {PRODUCTS} >= 0; param a {PRODUCTS, PRODUCTS} >=0; var x { PRODUCTS } >= 0; var y { PRODUCTS } >= 0; maximize profit: sum {i in PRODUCTS} (p[i]*y[i] - m[i]*x[i]); subject to limit{i in PRODUCTS}: x[i] <= Max[i]; subject to work: sum {i in PRODUCTS} h[i]*x[i]<= HMan; subject to balance{i in PRODUCTS} : y[i] + sum{j in PRODUCTS}(a[j,i]*x[j]) = x[i];
12
AMPL dat – Carelland
set PRODUCTS := steel plastics electronics engines; param HMan:= 830000; param : p m h Max := steel 500 250 0.5 2000000 plastics 1200 300 2 60000 electronics 300 50 0.5 650000 engines 1500 300 1 2000000 ; param a: steel plastics electronics engines := steel 0 0.01 0 0.02 plastics 0.2 0 0.05 0.03 electronics 0.01 0.05 0 0.01 engines 0.8 0.11 0.15 0 ;
13
Solution – Carelland
ILOG AMPL 10.100, licensed to "ecolepolytechnique-palaiseau". AMPL Version 20060626 (Linux 2.6.9-5.ELsmp) ILOG CPLEX 10.100, licensed to "ecolepolytechnique-palaiseau",
- ptions: e m b q use=8
CPLEX 10.1.0: optimal solution; objective 435431250 9 dual simplex iterations (6 in phase I) x [*] := electronics 74375 engines 475833 plastics 60000 steel 393958 ; y [*] := electronics 0 engines 465410 plastics 0 steel 547.917 ;
14
Dyeing problem
A fabric dyeing plant has 3 dyeing baths. Each batch of fabric must be dyed in each bath in the order: first, second, third bath. The plant must color five batches of fabric of different sizes. For each batch, the time for dyeing in each bath is known. Write a mathematical program for scheduling the dyeing operations in the baths so that the ending time of the last batch is minimized. Solve the problem with AMPL.
15
Dyeing problem: data
3 dyeing baths 5 batches Time (hours) for dyeing each batch in each bath:
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ 3 2 1 . 2 2 2 2 3 . 1 2 . 1 3 1 5 . 1 2 1 1 3
The element (i,k) is the time for dyeing batch i in bath k .
16
Writing the mathematical model
Preliminary observations
- Each batch must be dyed in the first bath, then in the second bath,….
The k-th bath must finish before that the (k+1)-th bath can start.
- The time for dyeing in the last bath must be bounded by the completion time
for last batch.
- Two different batches cannot be dyed in the same bath at the same time.
- If the bath i is to be dyed before batch j, then j cannot be dyed before i
(disjunction).
17
Mathematical model
- Parameters
∀ i∈ L, k∈ V sik : time necessary to dye batch i in bath k M : upper bound to completion time of last bath T: completion time for last batch tik: starting time for dyeing batch i in bath k yijk = 1 if batch i is to be dyed before batch j in bath k,
0 otherwise.
- Variables
- Sets
L : set of fabric batches L={1,…,l} V : set of dyeing baths V ={1,...,v}
18
Mathematical model
- Objective function
T min
we want to minimize the completion time of the last batch
- Constraints
( )
) 1 (
} { \ ,
+
≤ + ∈ ∈ ∀
k i ik ik
t s t v V k L i
( )
T s t L i
iv iv
≤ + ∈ ∀
( ) ( )
ijk jk ik ik
y M t s t j i V k L j i − + ≤ + ≠ ∈ ∈ ∀ 1 , , ,
( )
1 , , , = + ≠ ∈ ∈ ∀
jik ijk
y y j i V k L j i
- sequential:
- last bath:
- non overlapping:
- disjunction:
19
AMPL model – Dyeing
param l >= 1; param v >= 1; set L := 1..l; set V := 1..v; set V0 := 1..v-1; param s{L,V} >= 0; param M default sum{i in L, k in V} s[i,k] ; var t{L,V} >= 0; var T >= 0; var y{L,L,V} binary; minimize makespan : T; subject to sequential{i in L, k in V0} : t[i,k] + s[i,k] <= t[i,k+1]; subject to lastbath{i in L} : t[i,v] + s[i,v] <= T; subject to nonoverlap{i in L, j in L, k in V : i != j} : t[i,k] + s[i,k] <= t[j,k] + M * (1 - y[i,j,k]); subject to disjunction{i in L, j in L, k in V : i != j} : y[i,j,k] + y[j,i,k] = 1;
20
AMPL dat – Dyeing
param l := 5; param v := 3; param s : 1 2 3 := 1 3.0 1.0 1.0 2 2.0 1.5 1.0 3 3.0 1.2 1.3 4 2.0 2.0 2.0 5 2.1 2.0 3.0 ;
21
AMPL run – Dyeing
model dyeing.mod; data dyeing.dat;
- ption solver cplex;
solve; display makespan; for {i in L} { printf "batch %d : ", i; for {k in V} { printf "[%f] ", t[i,k]; } printf "\n"; }
22
Solution – Dyeing
ILOG AMPL 10.100, licensed to "ecolepolytechnique-palaiseau". AMPL Version 20060626 (Linux 2.6.9-5.ELsmp) ILOG CPLEX 10.100, licensed to "ecolepolytechnique-palaiseau", options: e m b q use=8 CPLEX 10.1.0: optimal integer solution; objective 14.1 1175 MIP simplex iterations 235 branch-and-bound nodes makespan = 14.1 batch 1 : [9.100000] [12.100000] [13.100000] batch 2 : [0.000000] [2.000000] [3.500000] batch 3 : [6.100000] [10.600000] [11.800000] batch 4 : [2.000000] [4.000000] [6.000000] batch 5 : [4.000000] [6.100000] [8.100000]