integer linear
play

Integer Linear Programming CONTACT@ADAMFURMANEK.PL - PowerPoint PPT Presentation

Integer Linear Programming CONTACT@ADAMFURMANEK.PL HTTP://BLOG.ADAMFURMANEK.PL FURMANEKADAM 1 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK About me Experienced with backend, frontend, mobile, desktop, ML, databases. Blogger,


  1. Integer Linear Programming CONTACT@ADAMFURMANEK.PL HTTP://BLOG.ADAMFURMANEK.PL FURMANEKADAM 1 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  2. About me Experienced with backend, frontend, mobile, desktop, ML, databases. Blogger, public speaker. Author of .NET Internals Cookbook. http://blog.adamfurmanek.pl contact@adamfurmanek.pl furmanekadam 2 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  3. Agenda Declarative programming at a glance. Some theory. Real life example. Implementation consideration. Summary. 3 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  4. Declarative programming 4 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  5. Declarative programming Paradigm that expresses the logic of a computation without describing its control flow. Declarative programming often considers programs as theories of a formal logic, and computations as deductions in that logic space. A high-level program that describes what a computation should perform. SELECT * FROM Orders 5 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  6. Declarative programming — why? Decouples problem formulation from solving process. Solving part can be replaced without modifying the formulation. Easier to optimise algorithms for because „the goal” is understandable for the machine. Can be used with little to no programming skills. Sometimes we don’t know how to solve it. 6 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  7. Example — RTS game We are playing RTS game. We are allowed to hire footmen and archers . Every footman costs 10 gold and 30 food. Every archer costs 20 gold, 25 food, and 10 wood. Footman’s attack is equal to 5, archer’s attack is equal to 7. Our population limit is set to 200 units. Every footman „costs” 1 unit, every archer „costs” 2 units. We have 1000 gold, 1000 food, and 200 wood. We want to get strongest possible army. 7 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  8. Units Gold Food Wood Footman 10 30 0 Archer 20 25 10 Attack Unit count Footman 5 1 Archer 7 2 Available gold Available food Available wood Max units count Constraint 1000 1000 200 200 8 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  9. Variables Variables: 𝑔 − 𝑔𝑝𝑝𝑢𝑛𝑓𝑜 𝑏 − 𝑏𝑠𝑑ℎ𝑓𝑠𝑡 Constraints: 𝑔 + 2 ⋅ 𝑏 ≤ 200 // population 10 ⋅ 𝑔 + 20 ⋅ 𝑏 ≤ 1000 // gold 30 ⋅ 𝑔 + 25 ⋅ 𝑏 ≤ 1000 // food 10 ⋅ 𝑏 ≤ 200 // wood Target value: 5 ⋅ 𝑔 + 7 ⋅ 𝑏 9 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  10. 10 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  11. Example 11 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  12. Example 12 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  13. Example Variables: 𝑇, 𝐹, 𝑂, 𝐸, 𝑁, 𝑃, 𝑆, 𝑍 ∈ 0, … , 9 and all different Constraints: 1000𝑇 + 100𝐹 + 10𝑂 + 𝐸 + 1000𝑁 + 100𝑃 + 10𝑆 + 𝐹 = 10000𝑁 + 1000𝑃 + 100𝑂 + 10𝐹 + 𝑍 13 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  14. Example 14 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  15. Real life examples RTS game = factory production allocation: ◦ We have available resources ◦ We have facitilies ◦ We want to plan work to maximize the production Send more money = pattern recognition: ◦ We know structure of a problem but doesn’t understand the latent factors Floor tiling = microchip transistor layout: ◦ We have transistors and gates of given size ◦ We want to minimize heat emission and the board size Others: BTS placement, power plant rooms layout, scheduling systems, items personalization and many more. 15 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  16. Some theory MIXED INTEGER LINEAR PROGRAMMING 16 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  17. 17 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  18. Mixed Integer Linear Programming Programming in mathematics means finding a solution to optimization problem. Linear Programming is a class of a problems with only linear constraints and with linear cost function. Mixed Integer Linear Programming is a class of a problems with integer constraint for some of variables. 18 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  19. Constraints We cannot multiply variables: We can add two variables: 𝑏 + 𝑐 𝑏 ⋅ 𝑐 We can multiply variable by We cannot use strict constraings constant: (greater than, less than, not equal) 5 ⋅ 𝑏 𝑏 < 10 We can constrain variable with lower/upper bound: 𝑏 ≤ 7 19 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  20. Cost function Notice that not hiring anyone was also a solution ! Problem may have zero, one, multiple or infinitely many solutions. We need to compare them. We use cost function to specify which one of them is the best. 20 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  21. Cutting plane method 21 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  22. Algorithms Basic algorithms: ◦ Cutting plane methods – we solve the problem without integer constraints (continuous version of the problem), and next we cut the plane to get smaller problem ◦ Branch and bound – we solve the problem without integer constraints, and next we bound some variables and perform next iteration MILP is NP-complete and we sometimes use heuristics: ◦ Tabu search ◦ Simulated annealing ◦ Ant colony optimization 22 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  23. What can we do? WE WILL IMPLEMENT WE WILL NOT IMPLEMENT Arithmetic: division, remainder, exponentation, roots. Boole’s logic. Comparisons: min, max, absolute value. Number theory: factorial, GCD. Multiplication. Algorithms: if condition, sorting, loops, lexicographical comparisons, Gray’s code, linear regression. Comparison Set operators: SOS type 1 and 2, approximation. Graph operators: MST, vertex/edge cover, max flow, operators. connectivity, shortest path, TSP. Turing machine. 23 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  24. Conjunction — AND operator (&&) We have two variables: 𝑏, 𝑐 . We want to create variable 𝑦 which is 𝑦 = 𝑏 && 𝑐 . Formula: 0 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 1 24 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  25. Conjunction — AND operator (&&) 0 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 1 If both 𝑏 and 𝑐 are 1 then 𝑦 must be 1 . If 𝑦 was 0 : 0 ≤ 1 + 1 − 2 ⋅ 0 ≤ 1 0 ≤ 2 − 0 ≤ 1 0 ≤ 2 ≤ 1 25 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  26. Conjunction — AND operator (&&) 0 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 1 If both 𝑏 and 𝑐 are 1 then 𝑦 must be 1 . If 𝑦 is 1 : 0 ≤ 1 + 1 − 2 ⋅ 1 ≤ 1 0 ≤ 2 − 2 ≤ 1 0 ≤ 0 ≤ 1 26 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  27. Conjunction — AND operator (&&) 0 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 1 If either 𝑏 or 𝑐 is 1 then 𝑦 must be 0. If 𝑦 was 1 : 0 ≤ 1 + 0 − 2 ⋅ 1 ≤ 1 0 ≤ 1 − 2 ≤ 1 0 ≤ −1 ≤ 1 27 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  28. Conjunction — AND operator (&&) 0 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 1 If either 𝑏 or 𝑐 is 1 then 𝑦 must be 0. If 𝑦 is 0 : 0 ≤ 1 + 0 − 2 ⋅ 0 ≤ 1 0 ≤ 1 − 0 ≤ 1 0 ≤ 1 ≤ 1 28 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  29. Conjunction — AND operator (&&) 0 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 1 If both 𝑏 or 𝑐 are 0 then 𝑦 must be 0. If 𝑦 was 1 : 0 ≤ 0 + 0 − 2 ⋅ 1 ≤ 1 0 ≤ 0 − 2 ≤ 1 0 ≤ −2 ≤ 1 29 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  30. Conjunction — AND operator (&&) 0 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 1 If both 𝑏 or 𝑐 are 0 then 𝑦 must be 0. If 𝑦 is 0 : 0 ≤ 0 + 0 − 2 ⋅ 0 ≤ 1 0 ≤ 0 − 0 ≤ 1 0 ≤ 0 ≤ 1 30 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  31. Conjunction — AND operator (&&) 0 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 1 If both 𝑏 and 𝑐 are 1 then 𝑦 must be 1 . If either 𝑏 or 𝑐 is 1 then 𝑦 must be 0. If both 𝑏 or 𝑐 are 0 then 𝑦 must be 0. 31 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  32. Conjunction & Disjunction Two variables conjunction: 0 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 1 𝑜 variables conjunction: 0 ≤ 𝑏 1 + 𝑏 2 + 𝑏 3 + … + 𝑏 𝑜 − 𝑜𝑦 ≤ 𝑜 − 1 Two variables disjunction: −1 ≤ 𝑏 + 𝑐 − 2𝑦 ≤ 0 𝑜 variables disjunction goes the same way 32 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  33. Negation, exclusive or, implication Negation: 𝑦 = 1 − 𝑏 Implication: 𝑏 ⇒ 𝑐 ≡ ~𝑏 ∨ 𝑐 Exclusive or: ~𝑏 ∧ 𝑐 ∨ (𝑏 ∧ ~𝑐) 33 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  34. Multiplication of two binary variables is their conjunction . 𝑏 ⋅ 𝑐 ≡ 𝑏 ∧ 𝑐 34 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

  35. Multiplication of integer variables Multiplication is possible when we know the maximum possible value of a variable. We set the upper bound and perform the long multiplication. It is rather slow approach, it requires 𝑃(𝑜 2 ) temporary variables. 35 25.07.2020 INTEGER LINEAR PROGRAMMING - ADAM FURMANEK

Recommend


More recommend