mathematical programming modelling and applications
play

Mathematical Programming: Modelling and Applications September 2009 - PowerPoint PPT Presentation

Mathematical Programming: Modelling and Applications September 2009 Sonia Cafieri LIX, cole Polytechnique cafieri@lix.polytechnique.fr Outline Some basic AMPL useful operations & commands A modelling problem Formulation of


  1. Mathematical Programming: Modelling and Applications September 2009 Sonia Cafieri LIX, École Polytechnique cafieri@lix.polytechnique.fr

  2. Outline � Some basic AMPL useful operations & commands � A modelling problem � Formulation of the mathematical model � The AMPL model � Solution of the problem 2

  3. AMPL basic set operations These operations become useful or necessary in many problems Let A, B, and U be sets � AMPL allows simple set operations: � � Union: U = A union B elements of A or B � Intersection: U = A inter B elements of A and B � Difference: U = A diff B elements of A and not of B Union : Example ampl: set MONTHS := {1,2,3,4}; ampl: set MONTHS0 := {0} union MONTHS; ampl: display MONTHS0; set MONTHS0 := 0 1 2 3 4; 3

  4. AMPL commands AMPL recognizes a lot of commands. Some commands you already know are, e.g.: � model: switch to model mode � data: switch to data mode � exit: exit AMPL � display: print model entities and expressions � let: change data values � …… � Other useful commands: � fix: freeze a variable at its current value � unfix: undo a fix command � delete: delete model entities � purge: delete model entities and their dependents � 4

  5. AMPL commands Note that fix, unfix, delete, purge , .. are used for changing a model : it is possible in AMPL modifying models and data. Fix : Example fix varname • This command instructs AMPL to treat the indicated variable as though fixed at its current value (e.g. in solve command): we have a constant. • If varname is the name of an indexed collection of variables, fix (and unfix) affects all members of the collection. • Fixing a variable we have a further constraint in the problem. 5

  6. AMPL commands: fix ampl: var y{1..4} >=1; ampl: let y[3] := 10; ampl: fix y[3]; ampl: display y[3]; y[3] = 10 ampl: minimize somma: sum{i in 1..4} y[i]; ampl: option solver cplex; ampl: solve; ILOG CPLEX 10.100, licensed to "ecolepolytechnique-palaiseau", options: e m b q use=8 CPLEX 10.1.0: optimal solution; objective 13 0 dual simplex iterations (0 in phase I) ampl: display y; y [*] := 1 1 2 1 3 10 4 1 ; 6

  7. Production planning problem A firm is planning the production of 3 products A1, A2, A3 over a time horizon of 4 months (January to April). We know: • The demand for the products over the 4 months; • Prices, production costs, production quotas, activation costs and minimum batches for each product; Furthermore: • There is a different number of productive days over the 4 months; • The activation status of a production line can be changed every month. • Minimum batches are monthly. • Each product needs to be stored. There are different monthly rates for renting the storage space for each product. • Each product takes the same amount of storage space. The total available volume is given. 7

  8. Production planning problem: data Demand for the products over the months: Demand January February March April A1 5300 1200 7400 5300 A2 4500 5400 6500 7200 A3 4400 6700 12500 13200 Prices, production costs, production quotas, activation costs and minimum batches: Product A1 A2 A3 Selling prices $124 $109 $115 Activation costs $150000 $150000 $100000 Production costs $73.30 $52.90 $65.40 Production quotas 500 450 550 Minimum batches 20 20 16 8

  9. Production planning problem: data Number of productive days over the months: January 23 February 20 March 23 April 22 Monthly rates for storage space: A1 $3.50 A2 $4.00 A3 $3.00 Total available volume: 800 units. Write a mathematical program to maximize the income, and solve it with AMPL. 9

  10. Writing the mathematical model Preliminary observations: • There are some quantities (parameters) defined for each product : selling price, production cost, production quota, activation cost, minimum batch, storage cost for each month: number of production days for each product and each month: maximum demand for each product in each month independently on product/month: storage capacit y. • Furthermore: For each product, there is a different quantity produced, sold, stocked during each month and the activation status of each production line is also dependent on the months. 10

  11. Writing the mathematical model Sets and indices: i ∈ • 3 products � use an index I j ∈ • 4 months � use an index J define parameters / variables indexed on i , j What decisions should we take? quantity produced product , month quantity sold j i quantity stocked also take into account the activation status 11

  12. Mathematical model • Parameters P j : number of production days in month j; d ij : maximum demand for product i in month j; v i : selling price for product i; c i : production cost of product i; q i : maximum production quota of product i; a i : activation cost for production i; b i : minimum batch for production i; s i : storage cost for product i; C : storage capacity in number of units. 12

  13. Mathematical model • Variables x ij : quantity of product i produced during month j; All variables are non w ij : quantity of product i sold during month j; negative z ij : quantity of product i stocked during month j; y ij : activation status for production i during month j; ⎧ 1 if product i is active during month j = ⎨ y ij binary y ij ⎩ 0 otherwise • Objective function maximize the total income total income: 3 products – sum income obtained during each month ⎛ ⎞ ∑ ∑ ∑ ∑ ∑ ⎜ ⎟ − − − max v w c x s z a y ⎜ ⎟ i ij i ij i ij i ij ⎝ ⎠ ∈ ∈ ∈ ∈ ∈ i I j J j J j J j J 13

  14. Mathematical model • Constraints ∀ ∈ ∈ ≤ • demand: i I , j J w d ij ij x ∑ ∀ ∈ ≤ ij • production: j J P j q ∈ i I i ∀ ∈ ∈ + = + • balance: i I , j J z x z w − 1 i , j ij ij ij ∑ ∀ ∈ ij ≤ • capacity: j J z C ∈ i I ∀ ∈ ∈ ≤ • activation: i I , j J x P q y ij j i ij ∀ ∈ ∈ ≥ • minimum batch: i I , j J x b y ij i ij ∀ ∈ 0 = • december: i I z 0 i 14

  15. AMPL model – production planning Starting from the mathematical formulation, try to code the AMPL model � We have 2 indices for many variables/constraints: i (products): A1, A2, A3 j (months): 1,2,3,4 It is useful to define 2 sets: set PRODUCTS; param Months; set MONTHS := 1..Months We also have z i0 -- index 0 set MONTHS0 := MONTHS union {0} 15

  16. AMPL model – production planning � Now we can define the parameters: all parameters are non negative param days{MONTHS} >= 0; param demand { PRODUCTS, MONTHS } >= 0; param price { PRODUCTS } >= 0; param cost { PRODUCTS } >= 0; param quota { PRODUCTS } >= 0; param activation { PRODUCTS } >= 0; param batch { PRODUCTS } >= 0; param storage { PRODUCTS } >= 0; param capacity >= 0; � Variables: var x { PRODUCTS, MONTHS } >= 0; var w { PRODUCTS, MONTHS } >= 0; var z { PRODUCTS, MONTHS0 } >= 0; var y { PRODUCTS, MONTHS } >= 0, binary; 16

  17. AMPL model – production planning � Objective function: maximize revenue: sum {i in PRODUCTS} (price[i] * sum {j in MONTHS} w[i,j] - cost[i] * sum {j in MONTHS} x[i,j] - storage[i] * sum {j in MONTHS} z[i,j] - activation[i] * sum {j in MONTHS} y[i,j]) ; � Constraints: subject to requirement {i in PRODUCTS, j in MONTHS}: w[i,j] <= demand[i,j]; subject to production {j in MONTHS}: sum {i in PRODUCTS} (x[i,j] / quota[i]) <= days[j]; subject to balance {i in PRODUCTS, j in MONTHS}: z[i,j-1] + x[i,j] = z[i,j] + w[i,j]; subject to capacitymag {j in MONTHS}: sum {i in PRODUCTS} z[i,j] <= capacity; subject to active {i in PRODUCTS, j in MONTHS}: x[i,j] <= days[j]*quota[i]*y[i,j]; subject to minbatch {i in PRODUCTS, j in MONTHS}: x[i,j] >= batch[i]*y[i,j]; 17

  18. AMPL dat – production planning set PRODUCTS := A1 A2 A3 ; param Months := 4 ; param days := 1 23 2 20 3 23 4 22 ; param demand: 1 2 3 4 := A1 5300 1200 7400 5300 A2 4500 5400 6500 7200 A3 4400 6700 12500 13200 ; param : price cost quota activation batch storage := A1 124 73.30 500 150000 20 3.5 A2 109 52.90 450 150000 20 4 A3 115 65.40 550 100000 16 3 ; param capacity := 800 ; let {i in PRODUCTS} z[i,0] := 0; fix {i in PRODUCTS} z[i,0]; 18

  19. AMPL run – production planning model productionplanning.mod; data productionplanning.dat; option solver cplex; solve; option display_round 4; display revenue; display x; display y; 19

  20. Solution – production planning 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 1581550 33 MIP simplex iterations 0 branch-and-bound nodes revenue = 1581550.0000 x := y := A1 1 6100.0000 A1 1 1.0000 A1 2 0.0000 A1 2 0.0000 A1 3 0.0000 A1 3 0.0000 A1 4 0.0000 A1 4 0.0000 A2 1 0.0000 A2 1 0.0000 A2 2 3518.1818 A2 2 1.0000 A2 3 0.0000 A2 3 0.0000 A2 4 0.0000 A2 4 0.0000 A3 1 4400.0000 A3 1 1.0000 A3 2 6700.0000 A3 2 1.0000 A3 3 12650.0000 A3 3 1.0000 A3 4 12100.0000 A3 4 1.0000 ; ; 20

Recommend


More recommend