Knapsack Model Notes 6 Intuitive idea: what is the most valuable collection of items that can be fit into a backpack? IE312 1 Race Car Features Cost (thousand) Speed increase (mph) $ 1 10.2 $ 8 Proposed Feature (j ) 2 3 4 6.0 $ 23.0 $ 11.1 $ 3 15 7 5 9.8 $ 10 6 31.6 12 Budget of $35,000 Which features should be added? Notes 6 IE312 2 Formulation Decision variables ILP 1 if feature j is added xj otherwise 0 max 8 x1 3x2 15 x3 7 x4 10 x5 12 x6 10.2 x1 6.0 x2 23.0 x3 11.1x4 9.8 x5 31.6 x6 35 s.t x j 0 or 1 Notes 6 IE312 3 LINGO Formulation Variables indexed by this set MODEL: SETS: Specify index sets FEATURES /F1,F2,F3,F4,F5,F6/: INCLUDE,SPEED_INC,COST; ENDSETS DATA: SPEED_INC = 8 3 15 7 10 12; All the constants COST = 10.2 6.0 23.0 11.1 9.8 31.6; Note ; to end command : to begin an environment BUDGET = 35; ENDDATA Objective MAX = @SUM( FEATURES: SPEED_INC * INCLUDE); Constraints @SUM( FEATURES: COST * INCLUDE) <= BUDGET; @FOR( FEATURES: @BIN( INCLUDE)); END Notes 6 IE312 Decision variables are binary 4 Solve using Branch & Bound x5 0 x5 1 Candidate Problem max 8 x1 3x2 15 x3 7 x4 12 x6 10.2 x1 6.0 x2 23.0 x3 11.1x4 31.6 x6 35 s.t Solution? x j 0 or 1 Relaxed Problem max 8 x1 3x2 15 x3 7 x4 12 x6 10.2 x1 6.0 x2 23.0 x3 11.1x4 31.6 x6 35 s.t x j [0,1] Notes 6 IE312 5 What is the Relative Worth? x1 : 8 0.78 Want to add this feature second 10.2 x2 : 3 0.5 6 x3 : 15 0.65 23 x4 : 7 0.63 11.1 x5 : 10 1.02 9.8 x6 : 12 0.38 31.6 Notes 6 Want to add this feature first IE312 6 Solve Relaxed Problem x5 0 x5 1 Relaxed Problem max 8 x1 3x2 15 x3 7 x4 12 x6 10.2 x1 6.0 x2 23.0 x3 11.1x4 31.6 x6 35 s.t x j [0,1] 8 1 15 1 7 0.257 Solution: x1 1 Still have $35 $10.2 $24.8 x3 1 Still have $24.8 $23.0 $1.8 x4 1.8 0.257 7 Notes 6 IE312 Objective 24.8 7 Now the other node… x5 0 x5 1 Relaxed Problem max 8 x1 3x2 15 x3 7 x4 12 x6 10 10.2 x1 6.0 x2 23.0 x3 11.1x4 31.6 x6 35 9.8 s.t x j [0,1] Solution: x1 1 Still have $25.2 $10.2 $15 x3 15 Notes 6 23 0.652 Objective 27.8 IE312 8 Next Step? x5 0 x5 1 Objective 24.8 Notes 6 Objective 27.8 IE312 9 Rule of Thumb: Better Value x5 0 Relaxed Problem x5 1 max 3x2 15 x3 7 x4 12 x6 18 6.0 x2 23.0 x3 11.1x4 31.6 x6 15 s.t Obj 24.8 x1 0 x1 1 Obj. 26.4 x j [0,1] Obj. 27.8 Relaxed Problem Solution: x3 15 23 0.652 max 3x2 15 x3 7 x4 12 x6 10 6.0 x2 23.0 x3 11.1x4 31.6 x6 25.2 s.t x j [0,1] Solution: x3 1 Still have $25.2 $23 $2.2 x4 2.2 Notes 6 11.1 0.198 IE312 10 Next Level Candidate Problem x5 0 max 3x2 7 x4 12 x6 18 6.0 x2 11.1x4 31.6 x6 15 s.t x5 1 x j 0,1 Obj 24.8 x1 0 x1 1 Solution: x4 1, x2 x6 0 Obj. 26.4 x3 0 x3 1 Obj. = 25 (This turns out to be true.) Infeasible Now What? Notes 6 IE312 11 Next Steps … x5 0 Still need to continue branching here. x5 1 Obj 24.8 Obj 25 Obj. 26.4 x1 0 x1 1 x3 0 x3 1 Obj. = 25 Notes 6 Infeasible IE312 Finally we will have accounted for every solution! 12 Capital Budgeting Notes 6 Multidimensional knapsack problems are often called capital budgeting problems Idea: select collection of projects, investments, etc, so that the value is maximized (subject to some resource constraints) IE312 13 NASA Capital Budgeting Budget Requirements 2000- 2005- 2010- 2015- 2020Not Depends j Mission 2004 2009 2014 2019 2024 Value With On 1 Communication satellite 6 200 2 Orbital microwave 2 3 3 3 Io lander 3 5 20 4 Uranus orbiter 2020 10 50 5 3 5 Uranus orbiter 2010 5 8 70 4 3 6 Mercury probe 1 8 4 20 3 7 Saturn probe 1 8 5 3 8 Infrared imaging 5 10 11 9 Ground-based SETI 4 5 200 14 10 Large orbital structures 8 4 150 11 Color imaging 2 7 18 8 2 12 Medical technology 5 7 8 13 Polar orbital platform 1 4 1 1 300 14 Geosynchronous SETI 4 5 3 3 185 9 Budget 10 12 14 14 14 Notes 6 IE312 14 Formulation Decision variables 1 if mission j is chosen xj otherwise 0 Budget constraints 6 x1 2 x2 3x3 1x7 4 x9 5x12 10 (year 1) Notes 6 IE312 15 Formulation Mutually exclusive choices x4 x5 1 x8 x11 1 x9 x14 1 Dependencies x11 x2 x4 x3 Notes 6 IE312 16 Set Packing, Covering, and Partitioning Notes 6 IE312 17 Select Locations Notes 6 IE312 18 Ways of Splitting the Set Set covering constraints x jJ 1 Set packing constraints x jJ j j 1 Set partitioning constraints x jJ Notes 6 j 1 IE312 19 Example: Choosing OR Software Software Package (j ) Algorithm 1 2 3 4 LP Yes Yes Yes Yes IP Yes Yes NLP Yes Yes Cost 3 4 6 14 Formulate a set covering problem to acquire the minimum cost software with LP, IP, and NLP capabilities. Formulate set partitioning and set packing problems. What goals do they meet? Notes 6 IE312 20 Maximum Coverage Perhaps the budget only allows $9000 What can we then do Maximum coverage How do we now formulate the problem? Need new variables 1 if ALG not provided yALG otherwise 0 Notes 6 IE312 21 Travelling Salesman Problem (TSP) Fort Dodge Waterloo Carroll Boone Ames Marshalltown West Des Moines Notes 6 IE312 What is the shortest route, starting in Ames, that visits each city exactly ones? 22 TSP Solution Fort Dodge Waterloo Carroll Boone Ames Marshalltown West Des Moines Notes 6 IE312 23 Not a TSP Solution Fort Dodge Waterloo Carroll Boone Ames Marshalltown West Des Moines Notes 6 IE312 24 Applications Routing of vehicles (planes, trucks, etc.) Routing of postal workers Drilling holes on printed circuit boards Routing robots through a warehouse, etc. Notes 6 IE312 25 Formulating TSP A TSP is symmetric if you can go both ways on every arc 1 if the route includes leg between i and j xi , j otherwise 0 min c i j i x j i Notes 6 i, j x i, j i, j 2 IE312 26 Example 10 1 1 1 1 5 2 3 10 10 4 1 1 1 6 Formulate a TSP Notes 6 IE312 27 Subtours Notes 6 It is not sufficient to have two arcs connected to each node Why? Must eliminate all subtours Every subset of points must be exited IE312 28 How do we eliminate subtours? 10 1 1 1 1 5 Notes 6 2 3 10 10 IE312 4 1 1 1 6 29 Asymmetric TSP Now we have decision variables 1 if the route goes from i to j xi , j otherwise 0 Constraints x j i i, j x j i Notes 6 j ,i 1 (leave i ) 1 (enter i ) IE312 30 Asymmetric TSP (cont.) Each tour must enter and leave every subset of points x iS jS Notes 6 i, j 1 Along with all variables being 0 or 1, this is a complete formulation IE312 31 Example 10 1 1 1 1 5 2 3 10 4 10 1 1 1 6 Assume a two unit penalty for passing from a high to lower numbered node. This is now an asymmetric TSP. Why? Notes 6 IE312 32 Subtour Elimination Making sure there are no subtours involves a very large number of constraints Can obtain simpler constraints if we go with a nonlinear objective function y k ,i Notes 6 1 if the kth point visi ted is i otherwise 0 IE312 33 Quadratic Assignment Formulation min d y y 1 i, j i j k ,i yk 1, j k k ,i i y k ,i 1 k yk ,i 0,1 Notes 6 IE312 34 Example: reformulate 10 1 1 1 1 5 Notes 6 2 3 10 10 IE312 4 1 1 1 6 35