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 � Solution � Another modelling problem: Dyeing � Formulation of the mathematical model � The AMPL model � Solution 2
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 . 3
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. 4
Carelland: data Unit prices on the world markets : steel 500 engines 1500 electronics 300 plastics 1200 Maximum possible production: steel -- engines -- electronics 650000 plastics 60000 Total available workforce: 830000 man-year. 5
Writing the mathematical model • Parameters and Sets Consider a set containing the products. What are the parameters? • 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. • Objective function What do we have to maximize? Note: the profits can be expressed in terms of exported quantities and produced quantities. 6
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 other product. Then, try to write these constraints in a more compact form. 7
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) M i : maximum possible production for product i ∈ P h i : amount of work required to manufacture a unit of product i ∈ P m i : price of raw materials necessary to manufacture a unit of product i ∈ P p i : market price for product i ∈ P • Variables x a , x m , x e , x p : produced units of steel, engines, electronics and plastics y a , y m , y e , y p : exported units of steel, engines, electronics and plastics All variables are non negative 8
Mathematical model • Objective function maximize the profits profits: exported quantities minus produced quantities ∑ ∑ − max p y m x i i i i ∈ ∈ i P i P • Constraints ∑ ≤ h x H i i - amount of work: ∈ i P ∀ ∈ ≤ - maximum production: i P x M i i - balance: = + + + x y 0 . 8 x 0 . 01 x 0 . 2 x a a m e p = + + + x y 0 . 02 x 0 . 01 x 0 . 03 x m m a e p = + + x y 0 . 15 x 0 . 05 x e e m p = + + + x y 0 . 01 x 0 . 11 x 0 . 05 x p p a m e 9
Mathematical model Note that the following constraints = + + + x y 0 . 8 x 0 . 01 x 0 . 2 x a a m e p = + + + x y 0 . 02 x 0 . 01 x 0 . 03 x m m a e p = + + x y 0 . 15 x 0 . 05 x e e m p = + + + x y 0 . 01 x 0 . 11 x 0 . 05 x p p a m e can be written as: ∑ ∀ ∈ = + i P x y a x i i ji j ∈ j P where: = ⎧ 0 if i j ⎪ units of product i ∀ ∈ = ⎨ i , j P a ij needed to produce otherwise ⎪ ⎩ 1 unit of product j 10
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]; 11
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 ; 12
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", options: 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 ; 13
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. 14
Dyeing problem: data 3 dyeing baths 5 batches Time (hours) for dyeing each batch in each bath : ⎛ ⎞ 3 1 1 ⎜ ⎟ ⎜ ⎟ 2 1 . 5 1 ⎜ ⎟ 3 1 . 2 1 . 3 ⎜ ⎟ ⎜ ⎟ 2 2 2 ⎜ ⎟ ⎝ ⎠ 2 . 1 2 3 The element ( i,k ) is the time for dyeing batch i in bath k . 15
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). 16
Mathematical model • Sets L : set of fabric batches L= { 1,…,l } V : set of dyeing baths V = { 1,...,v } • Parameters ∀ i ∈ L, k ∈ V s ik : time necessary to dye batch i in bath k M : upper bound to completion time of last bath • Variables T : completion time for last batch t ik : starting time for dyeing batch i in bath k y ijk = 1 if batch i is to be dyed before batch j in bath k , 0 otherwise. 17
Mathematical model • Objective function we want to minimize the completion time of the last batch min T • Constraints ( ) - sequential: ∀ ∈ ∈ + ≤ i L , k V \ { v } t s t + ik ik i ( k 1 ) ( ) ∀ ∈ + ≤ - last bath: i L t s T iv iv ( ( ) ) ∀ ∈ ∈ ≠ + ≤ + − - non overlapping: i , j L , k V , i j t s t M 1 y ik ik jk ijk ( ) ∀ ∈ ∈ ≠ + = - disjunction: i , j L , k V , i j y y 1 ijk jik 18
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; 19
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 ; 20
Recommend
More recommend