outline optimisation discrete
play

Outline Optimisation Discrete Introduction 1 Solving the Knapsack - PowerPoint PPT Presentation

Outline Optimisation Discrete Introduction 1 Solving the Knapsack Problem Heuristics for the Knapsack Problem 2 Solving the Continuous Knapsack Problem Sonia Cafieri 3 ENAC Exact solution of the KP 4 Branch and Bound algorithms for IP


  1. Outline Optimisation Discrete Introduction 1 Solving the Knapsack Problem Heuristics for the Knapsack Problem 2 Solving the Continuous Knapsack Problem Sonia Cafieri 3 ENAC Exact solution of the KP 4 Branch and Bound algorithms for IP sonia.cafieri@enac.fr Branch and Bound for the KP Branch and Bound for IP : Remarks logoenac logoenac S. Cafieri (ENAC) Knapsack Problem 2016-2017 1 / 55 S. Cafieri (ENAC) Knapsack Problem 2016-2017 2 / 55 Knapsack problem (KP) Solving the KP There is no polynomial algorithm known that solves the problem to optimality. There is also no proof that such an algorithm does not exist. How to solve the Knapsack problem? Apply an algorithm with exponential running time to find an optimal solution Enumerate all possible solutions in a smart way to find an optimal solution : branch-and-bound or dynamical programming  n �  max x i u i V = volume of the knapsack   Apply a polynomial algorithm that constructs a good but possibly non-optimal    i = 1 v i = volume of object i  solution : heuristic approach. n � s . t . x i v i ≤ V u i = value of object i     i = 1 x i = 1 if object i is selected, 0 otherwise   x i ∈ { 0 , 1 } ∀ i  logoenac logoenac S. Cafieri (ENAC) Knapsack Problem 2016-2017 4 / 55 S. Cafieri (ENAC) Knapsack Problem 2016-2017 5 / 55

  2. Heuristics for KP : Greedy algorithm Greedy algorithm for KP Greedy : algorithm that makes the choice that looks the best at the moment. W ← 0 Idea : sort by most rewarding items Sort by most rewarding items with respect to a given criterion for i = 1 , . . . , n do and take as many of the top most valuable items as will fit. W ← v i + W if ( W ≤ V ) then Heuristic 1 : i ∈ { 1 , . . . , n } by non-increasing order sort u i x i ← 1 else Heuristic 2 : i ∈ { 1 , . . . , n } by increasing order sort v i x i ← 0 W ← W − v i Heuristic 3 : sort u i / v i i ∈ { 1 , . . . , n } by non-increasing order endif ⇒ the most efficient greedy endfor logoenac logoenac S. Cafieri (ENAC) Knapsack Problem 2016-2017 7 / 55 S. Cafieri (ENAC) Knapsack Problem 2016-2017 8 / 55 0-1 Knapsack and Continuous Knapsack Solving the CKP 0-1 Knapsack Problem: Greedy n.3 you can only choose to take all (1) or nothing (0) of a particular item Idea : Sort by most rewarding items with respect to the ratio of value to size, and take as much Continuous Knapsack Problem (CNP): as possible of the most valuable items as will fit. you can take any fractions of the items to put in the knapsack Steps : ⇒ continuous relaxation of 0-1 Knapsack compute ratios (densities) u i / v i 1 For both versions : sort them by non-increasing order 2 Optimal Substructure property: take as much as possible of the densest item not already in the bag 3 an optimal solution contains within it optimal solutions to subproblems. If we remove item i from an optimal solution, then the remaining items must be optimal for Complexity : O ( n log n ) for sorting, O ( n ) for greedy choices the subproblem where the bag volume is V − v i and the available items do not include item i . Otherwise, we would be able to construct an even better solution than the optimal one. logoenac logoenac S. Cafieri (ENAC) Knapsack Problem 2016-2017 10 / 55 S. Cafieri (ENAC) Knapsack Problem 2016-2017 11 / 55

  3. Solving the CKP Solving exactly the CKP Greedy n.3 Theorem Sort values/volumes by non-increasing order. Let i j be the indexes of the objects after sorting ( u i j / v i j with j = 1 is the maximum The Greedy algorithm (n.3) is optimal for the Continuous Knapsack Problem (CKP) ratio): (continuous relaxation of 0-1 Knapsack) u i 1 ≥ u i 2 ≥ · · · ≥ u i n v i 1 v i 2 v i n Proof. 1 Note that the algorithm fills the knapsack completely. W ← 0 It may take a fraction of an item, which can only be the last selected item. for i ≤ n do The greedy solution is such that there exists a h such that if ( W + v i j ≤ V ) then x i j ← 1 / ∗ take item i ∗ / 1 = x i 1 = x i 2 = · · · = x i h > x i h + 1 > x i h + 2 = · · · = x i n = 0 . W ← W + v i j else We compare this solution with another (feasible) solution y i 1 , . . . , y i n . x i h ← V − W Let k be the smallest index such that y i k < 1, and / ∗ take a fraction of item i ∗ / v i h let ℓ be the smallest index such that k < ℓ and y i ℓ > 0. x i j ← 0 ∀ j > h (such an ℓ exists, otherwise the y solution would be equal to the x solution). endif logoenac logoenac endfor S. Cafieri (ENAC) Knapsack Problem 2016-2017 12 / 55 S. Cafieri (ENAC) Knapsack Problem 2016-2017 13 / 55 Solving exactly the CKP Solving exactly the CKP Theorem Proof. (cont.) The Greedy algorithm (n.3) is optimal for the Continuous Knapsack Problem (CKP) We increase y i k and decrease y i ℓ , while keeping all other values equal. (continuous relaxation of 0-1 Knapsack) Let ǫ = min { v i k ( 1 − y i k ) , v i ℓ y i ℓ } . ǫ ǫ We increase y i k by and decrease y i ℓ by , obtaining a new solution. Proof. 2 v i k v i ℓ Let O = { o 1 , o 2 , . . . , o n } be the optimal solution and G = { g 1 , g 2 , . . . , g n } be the This new solution is no worse than the y solution. greedy solution (where the items are ordered with respect to the greedy choice) . Moreover, either y i k has become 1, or y i ℓ has become 0. We show that there exist an optimal solution such that it also takes the greedy choice Repeating the same argument we find the solution x of the greedy. in each iteration. First, we show that an optimal solution selects (a fraction or 1 unit of) item g 1 . logoenac logoenac S. Cafieri (ENAC) Knapsack Problem 2016-2017 14 / 55 S. Cafieri (ENAC) Knapsack Problem 2016-2017 15 / 55

  4. Solving exactly the CKP Solving exactly the CKP Proof. 2 (cont.) Two cases: G takes 1 unit of g 1 . 1 Proof. 2 (cont.) If O also takes 1 unit of g 1 , done. Second, we observe that If O doesn’t take 1 unit of g 1 , then we take away volume v g 1 from O and put 1 after each greedy choice is made, we have a problem of the same form as unit of g 1 to it ⇒ new solution O ′ . Of course O ′ has the same volume constraint V as O . the original one. Moreover, g 1 has maximum ratio u / v . The problem exhibits the optimal substructure property ⇒ O ′ is as good as O ⇒ g 1 ∈ O ′ and O ′ is an optimal solution. ⇒ G ≡ O . G takes a fraction f of g 1 (the volume added to O is f × v g 1 ). 2 If O also takes a fraction f of g 1 , done. If O takes less than f of g 1 (cannot take more because o optimal), then we take away f × v g 1 from O and put f of g 1 to it ⇒ new solution O ′ . As before, O ′ is as good as O (otherwise contradiction). logoenac logoenac S. Cafieri (ENAC) Knapsack Problem 2016-2017 16 / 55 S. Cafieri (ENAC) Knapsack Problem 2016-2017 17 / 55 Solving exactly the CKP Solving exactly the CKP (Another) Alternative Proof: The simplex algorithm for solving the CKP takes exactly the same steps as the greedy. (Another) Alternative Proof: (cont.) Let i h be such that :  x n + 1 = 1 − x i 1 ∀ j ∈ { 1 , . . . , h } ← x i j 1    = 1 − x i 2 x n + 2 ∀ j ∈ { h + 2 , . . . , n } ← x i j 0      . V − � h  . j = 1 v i j  . x i h + 1 ← = 1 − x i n v i h + 1 x 2 n    V − � n  = x 2 n + 1 j = 1 v i j x i j   that is, i h is such that:   � n  z = j = 1 u i j x i j h h + 1  � � v i j ≤ V v i j > V and j = 1 j = 1 Let us apply the simplex algorithm with the dictionary representation. logoenac logoenac S. Cafieri (ENAC) Knapsack Problem 2016-2017 18 / 55 S. Cafieri (ENAC) Knapsack Problem 2016-2017 19 / 55

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend