more on modeling
play

More on Modeling Marco Chiarandini Department of Mathematics & - PowerPoint PPT Presentation

DM545 Linear and Integer Programming Lecture 14 More on Modeling Marco Chiarandini Department of Mathematics & Computer Science University of Southern Denmark Modeling with IP, BIP, MIP Outline ILP in Spreadsheet 1. Modeling with IP,


  1. DM545 Linear and Integer Programming Lecture 14 More on Modeling Marco Chiarandini Department of Mathematics & Computer Science University of Southern Denmark

  2. Modeling with IP, BIP, MIP Outline ILP in Spreadsheet 1. Modeling with IP, BIP, MIP 2. ILP in Spreadsheet 2

  3. Modeling with IP, BIP, MIP Outline ILP in Spreadsheet 1. Modeling with IP, BIP, MIP 2. ILP in Spreadsheet 6

  4. Modeling with IP, BIP, MIP Modeling with IP, BIP, MIP ILP in Spreadsheet (see also lec. 9) Iterate: 1. define parameters 2. define variables 3. use variables to express objective function 4. use variables to express constraints a. problems with discrete input/output (knapsack, factory planning) b. problems with logical conditions c. combinatorial problems (sequencing, allocation, transport, assignment, partitioning) d. network problems 7

  5. Modeling with IP, BIP, MIP ILP in Spreadsheet Variables ∈ Z n discrete quantities ∈ B n decision variables ∈ B n indicator/auxiliary variables (for logical conditions) ∈ B n special ordered sets ∈ B n incidence vector of S Assignment �� � max c i ,σ ( i ) | σ : I → J σ i TSP �� � min c i ,π ( i ) | π : { 1 .. n } → { 1 .. n } and π is a circuit π i COP     � min c j | S ∈ F S ⊆ N   j ∈ S 8

  6. Modeling with IP, BIP, MIP Logical Conditions ILP in Spreadsheet x binary y integer z continuous Linking constraints z ∈ R , x ∈ B if z = 0 then x = 0, if z > 0 then x = 1 z − Mx ≤ 0 � x = 1 = ⇒ z > m z − mx ≤ 0 � Logical conditions and 0 − 1 variables X 1 ∨ X 2 ⇐ ⇒ x 1 + x 2 ≥ 1 X 1 ∧ X 2 ⇐ ⇒ x 1 = 1 , x 2 = 1 ¬ X 1 ⇐ ⇒ x 1 = 0 or ( 1 − x 1 = 1 ) X 1 → X 2 ⇐ ⇒ x 1 − x 2 ≤ 0 X 1 ↔ X 2 ⇐ ⇒ x 1 − x 2 = 0 9

  7. Modeling with IP, BIP, MIP Examples ILP in Spreadsheet • ( X A ∨ X B ) → ( X C ∨ X D ∨ X E ) x A + x B ≥ 1 x C + x D + x E ≥ 1 x A + x B ≥ 1 = ⇒ x = 1 x = 1 = ⇒ x C + x D + x E ≥ 1 x A + x B − 2 x ≤ 0 x C + x D + x E ≥ x • Disjunctive constraints (encountered earlier) • Constraint: x 1 x 2 = 0 1) replace x 1 x 2 by x 3 2) x 3 = 1 ⇐ ⇒ x 1 = 1 , x 2 = 1 − x 1 + x 3 ≤ 0 − x 2 + x 3 ≤ 0 x 1 + x 2 − x 3 ≤ 1 10

  8. Modeling with IP, BIP, MIP ILP in Spreadsheet • z · x , z ∈ R , x ∈ B 1) replace zx by z 1 2) impose: x = 0 ⇐ ⇒ z 1 = 0 x = 1 ⇐ ⇒ z 1 = z z 1 − Mx ≤ 0 − z + z 1 ≤ 0 z − z 1 + Mx ≤ M • Special ordered sets of type 1/2 (for continuous or integer vars): SOS1: set of vars within which exactly one must be non-zero SOS2: set of vars within which at most two can be non-zero. The two variables must be adjacent in the ordering • separable programming and piecewise linear functions (next 5 slides) 11

  9. Modeling with IP, BIP, MIP Separable Programming ILP in Spreadsheet • Separable functions: sum of functions of single variables: 1 + 2 x 2 + e x 3 x 2 YES x 2 x 1 x 2 + x 1 + 1 + x 3 NO (actually, some non-separable can also be made separable: 1. x 1 x 2 by y 2. relate y to x 1 and x 2 by: log y = log x 1 + log x 2 needs care if x 1 and x 2 close to zero.) • non-linear separable functions can be approximated by piecewise linear functions (valid for both constraints and objective functions) 12

  10. Modeling with IP, BIP, MIP Convex Non-linear Functions ILP in Spreadsheet • We can model convex non-linear functions by piece-wise linear functions and LP min x 2 x 2 − 4 x 1 − 2 x 2 1 x 1 + x 2 ≤ 4 x 2 1 2 x 1 + x 2 ≤ 5 − x 1 + 4 x 2 ≥ 2 x 1 , x 2 ≥ 0 x 1 a 1 a 2 a 3 • LP Formulation x = λ 0 a 0 + λ 1 a 1 + λ 2 a 2 + λ 3 a 3 y = λ 0 f ( a 0 ) + λ 1 f ( a 1 ) + λ 2 f ( a 2 ) + λ 3 f ( a 3 ) � 3 i = 0 λ i = 1 λ i ≥ 0 i = 0 , . . . , 3 at most two adjacent λ i can be non zero (*) 13

  11. Modeling with IP, BIP, MIP ILP in Spreadsheet • To model (*) which are SOS2 we would need binary indicator variables and hence BIP as in next slide. • However since the problem is convex, an optimal solution lies on the borders of the functions and hence we can skip introducing the binary variables and relax (*) 14

  12. Non-convex Functions Modeling with IP, BIP, MIP ILP in Spreadsheet Piece-wise Linear Functions • non-convex functions require indicator variables and IP formulation � g ( x ) = g j ( x ) g j non linear j • approximated by f ( x ) piecewise linear in the disjoint intervals [ a i , b i ] • convex hull formulation (convex combination of points)   x = λ i a i + µ i b i � y = λ i f ( a i ) + µ i f ( b i ) Remember how we modeled disjunctive   λ i + µ i = 1 λ i , µ i ≥ 0 i ∈ I polyhedra... (cntd) 15

  13. Modeling with IP, BIP, MIP ILP in Spreadsheet • using indicator variables δ s we obtain the BIP formulation: x = � i ∈ I ( λ i a i + µ i b i ) y = � i ∈ I ( λ i f ( a i ) + µ i f ( b i )) λ i + µ i = δ i ∀ i ∈ I � i ∈ I δ i = 1 λ i , µ i ≥ 0 ∀ i ∈ I δ i ∈ { 0 , 1 } ∀ i ∈ I the δ s are SOS1. 16

  14. Modeling with IP, BIP, MIP Good/Bad Models ILP in Spreadsheet • Number of variables: sometimes it may be advantageous increasing if they are used in search tree. 0 − 1 var have specialized algorithms for preprocessing and for branch and bound. Hence a large number solved efficiently. Good using. Binary expansion: 0 ≤ y ≤ u y = x 0 + 2 x 1 + 4 x 2 + 8 x 3 + . . . + 2 r x r r = log 2 u • Making explicit good variables for branching: � a j x j ≤ b j � a j x j + u = b j u may be a good variable to branch ( u is relaxed in LP but must be integer as well) 17

  15. Modeling with IP, BIP, MIP ILP in Spreadsheet • Symmetry breaking: Eg machine maintenance (in FPMM) y j ∈ Z vs x j ∈ B • Difficulty of LP models depends on number of constraints: � � � z + z ′ t − z − min | a t z t − b t | max max t t t t t z + z ′ t − z − t ≥ a t z t − b 1 t = a t z t − b t z ′ t ≥ b t − a t z t more variables but less constraints • With IP it might be instead better increasing the number of constraints. • Make big M as small as possible in IP (reduces feasible region possibly fitting it to convex hull). 18

  16. Modeling with IP, BIP, MIP Practical Tips ILP in Spreadsheet • Units of measure: check them! all data should be scaled to stay in 0 . 1 − 10 some software do this automatically • Write few lines of text describing what the equations express and which are the variables, give examples on the problem modeled. • Try the model on small simple example that can be checked by hand. • Be diffident of infeasibility and unboundedness, double check. • Estimate the potential size. If IP problem large and no structure then it might be hard. If TUM then solvable with very large size If other structure, eg, packing, covering also solvable with large size • Check the output of the solver and understand what is happening • If all fail resort to heuristics 19

  17. Modeling with IP, BIP, MIP Outline ILP in Spreadsheet 1. Modeling with IP, BIP, MIP 2. ILP in Spreadsheet 20

  18. Modeling with IP, BIP, MIP ILP in Excel ILP in Spreadsheet A company produces the same product at two different factories ( A and B ) and then the product must be shipped to two warehouses, where either factory can supply either warehouse. The distribution network is shown below where C is a distribution center. There are costs and bounds on the amount of product to ship through the connections A D 0 // ∞ , 9 50 − 30 0 // ∞ , 4 0 // 10 , 2 0 // ∞ , 3 0 // ∞ , 2 C 0 0 // ∞ , 3 0 // 80 , 1 B E 40 − 60 What problem is it? Transhippment problem (ie, min cost flow) 21

  19. Modeling with IP, BIP, MIP ILP in Spreadsheet See file mincost.xlsx If Solver is not there, click Tools , select Add-Ins , Solver Add-in and OK. Then Tools , Solve What if � b ( v ) � = 0? 22

  20. Conclusions Modeling with IP, BIP, MIP ILP in Spreadsheet Optimization Taxonomy 23

Recommend


More recommend