580 likes | 603 Views
Use the Knapsack Model to determine the most valuable collection of items that can fit into a backpack with a budget of $35,000. Solve the problem using ILP and LINGO formulation.
E N D
Knapsack Model • Intuitive idea: what is the most valuable collection of items that can be fit into a backpack? IE 312
Race Car Features Budget of $35,000 Which features should be added? IE 312
Formulation • Decision variables • ILP IE 312
LINGO Formulation MODEL: SETS: FEATURES /F1,F2,F3,F4,F5,F6/: INCLUDE,SPEED_INC,COST; ENDSETS DATA: SPEED_INC = 8 3 15 7 10 12; COST = 10.2 6.0 23.0 11.1 9.8 31.6; BUDGET = 35; ENDDATA MAX = @SUM( FEATURES: SPEED_INC * INCLUDE); @SUM( FEATURES: COST * INCLUDE) <= BUDGET; @FOR( FEATURES: @BIN( INCLUDE)); END Variables indexed by this set Specify index sets Note ; to end command : to begin an environment All the constants Objective Constraints Decision variables are binary IE 312
Solve using Branch & Bound Candidate Problem Relaxed Problem Solution? IE 312
What is the Relative Worth? Want to add this feature second Want to add this feature first IE 312
Solve Relaxed Problem Relaxed Problem Solution: Objective <= 24.8 IE 312
Now the other node… Relaxed Problem Solution: Objective <= 27.8 IE 312
Next Step? Objective <= 24.8 Objective <= 27.8 IE 312
Relaxed Problem Solution: Obj. <=26.4 Obj. <= 27.8 Relaxed Problem Solution: Rule of Thumb: Better Value Obj <= 24.8 IE 312
Next Level Obj <= 24.8 Obj. <=26.4 Obj. = 25 Infeasible Now What? IE 312
Next Steps … Still need to continue branching here. Obj <= 24.8 Obj. <= 26.4 Finally we will have accounted for every solution! Obj. = 25 Infeasible IE 312
Capital Budgeting • 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) IE 312
NASA Capital Budgeting IE 312
Formulation • Decision variables • Budget constraints IE 312
Formulation • Mutually exclusive choices • Dependencies IE 312
Assignment Problems • Assignment problems deal with optimal pairing or matching of objects in two distinct sets • Decision variable • Let A be the set of allowed assignments and cij be the cost of assigning i to j. IE 312
Formulation IE 312
Example • We must determine how jobs should be assigned to machines to minimize setup times, which are given below: IE 312
Hungarian Algorithm • Step 1: (a) Find the minimum element in each row of the cost matrix. Form a new matrix by subtracting this cost from each row. (b) Find the minimum cost in each column of the new matrix, and subtract this from each column. This is the reduced cost matrix. IE 312
Example: Step 1(a) IE 312
Example: Step 1(b) IE 312
Hungarian Algorithm • Step 2: Draw the minimum number of lines that are needed to cover all the zeros in the reduced cost matrix. If m lines are required, then an optimal solution is available among the covered zeros in the matrix. Otherwise, continue to Step 3. IE 312
Example: Step 2 We need 3<4 lines, so continue to Step 3 IE 312
Hungarian Algorithm • Step 3: Find the smallest nonzero element (say, k) in the reduced cost matrix that is uncovered by the lines. Subtract k from each uncovered element, and add k to each element that is covered by two lines. Return to Step 2. IE 312
Example: Step 3 IE 312
Example: Step 2 (again) Need 4 lines, so we have the optimal assignment and we stop IE 312
Example: Final Solution Optimal assignment IE 312
Travelling Salesman Problem (TSP) Fort Dodge Waterloo Boone Ames Carroll Marshalltown What is the shortest route, starting in Ames, that visits each city exactly ones? West Des Moines IE 312
TSP Solution Fort Dodge Waterloo Boone Ames Carroll Marshalltown West Des Moines IE 312
Not a TSP Solution Fort Dodge Waterloo Boone Ames Carroll Marshalltown West Des Moines IE 312
Applications • Routing of vehicles (planes, trucks, etc.) • Routing of postal workers • Drilling holes on printed circuit boards • Routing robots through a warehouse, etc. IE 312
Formulating TSP • A TSP is symmetric if you can go both ways on every arc IE 312
10 1 2 1 1 1 10 1 3 4 1 1 10 5 6 Example Formulate a TSP IE 312
Subtours • It is not sufficient to have two arcs connected to each node • Why? • Must eliminate all subtours • Every subset of points must be exited IE 312
10 1 2 1 1 1 10 1 3 4 1 1 10 5 6 How do we eliminate subtours? IE 312
Asymmetric TSP • Now we have decision variables • Constraints IE 312
Asymmetric TSP (cont.) • Each tour must enter and leave every subset of points • Along with all variables being 0 or 1, this is a complete formulation IE 312
10 1 2 1 1 1 10 1 3 4 1 1 10 5 6 Example Assume a two unit penalty for passing from a high to lower numbered node. This is now an asymmetric TSP. Why? IE 312
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 IE 312
10 1 2 1 1 1 10 1 3 4 1 1 10 5 6 Example: reformulate IE 312
Solving TSP • We can use branch-and-bound to get an exact solution to the TSP problem • As always, the key to implementing branch-and-bound is to relax the problem so that we can easily solve the relaxed problem, but we still get good bounds • How can we relax the TSP? IE 312
Reduces to the assignment problem Relaxing the TSP IE 312
Branching Which cities should be selected? What is the most important variable? IE 312
Example: Solution to Assignment Problem Ames CR IC DSM IE 312
Branching Always branch to split up the subtours! Solving the assignment problem will hopefully yield a feasible solution soon. IE 312
Solution to New Assignment Problem (Left Branch) This makes both subtours impossible, so we get Ames CR IC DSM Thus, optimal solution is found by solving a total of three assignment problems! IE 312
Poor Branching Examples IE 312