MTHSC 4420 Advanced Mathematical Programming Homework 2

Similar documents
Operations Research Lecture 6: Integer Programming

MVE165/MMG630, Applied Optimization Lecture 6 Integer linear programming: models and applications; complexity. Ann-Brith Strömberg

Review Questions, Final Exam

Column Generation. i = 1,, 255;

5 Integer Linear Programming (ILP) E. Amaldi Foundations of Operations Research Politecnico di Milano 1

What is an integer program? Modelling with Integer Variables. Mixed Integer Program. Let us start with a linear program: max cx s.t.

Network Flows. 6. Lagrangian Relaxation. Programming. Fall 2010 Instructor: Dr. Masoud Yaghini

Integer Linear Programming Modeling

19. Fixed costs and variable bounds

Section Notes 9. IP: Cutting Planes. Applied Math 121. Week of April 12, 2010

Strong formulation for fixed charge network flow problem

Introduction to Bin Packing Problems

Chapter 3: Discrete Optimization Integer Programming

3.10 Lagrangian relaxation

DM559/DM545 Linear and integer programming

Chapter 3: Discrete Optimization Integer Programming

Introduction to Integer Linear Programming

Solutions to Exercises

3.7 Cutting plane methods

Discrete (and Continuous) Optimization WI4 131

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

Integer Linear Programming (ILP)

Combinatorial optimization problems

Section Notes 9. Midterm 2 Review. Applied Math / Engineering Sciences 121. Week of December 3, 2018

Discrete (and Continuous) Optimization Solutions of Exercises 2 WI4 131

Introduction to Integer Programming

x 1 + 4x 2 = 5, 7x 1 + 5x 2 + 2x 3 4,

Lecture 8: Column Generation

Column Generation I. Teo Chung-Piaw (NUS)

Introduction to integer programming II

Lecture 23 Branch-and-Bound Algorithm. November 3, 2009

Large-scale optimization and decomposition methods: outline. Column Generation and Cutting Plane methods: a unified view

Integer Programming Part II

Linear Programming Duality

IE 5531: Engineering Optimization I

Spring 2018 IE 102. Operations Research and Mathematical Programming Part 2

3.10 Column generation method

Optimization Methods in Management Science

Decomposition Methods for Integer Programming

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

CS 598RM: Algorithmic Game Theory, Spring Practice Exam Solutions

Lecture 8: Column Generation

Technische Universität München, Zentrum Mathematik Lehrstuhl für Angewandte Geometrie und Diskrete Mathematik. Combinatorial Optimization (MA 4502)

COT 6936: Topics in Algorithms! Giri Narasimhan. ECS 254A / EC 2443; Phone: x3748

21. Set cover and TSP

Mat 3770 Bin Packing or

Lecture 18: More NP-Complete Problems

3.10 Column generation method

21. Solve the LP given in Exercise 19 using the big-m method discussed in Exercise 20.

Written Exam Linear and Integer Programming (DM545)

Maximum Flow Problem (Ford and Fulkerson, 1956)

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

Optimization Methods in Finance - Homework II (Solutions)

Lecture 9: Dantzig-Wolfe Decomposition

- Well-characterized problems, min-max relations, approximate certificates. - LP problems in the standard form, primal and dual linear programs

Topics in Approximation Algorithms Solution for Homework 3

15.081J/6.251J Introduction to Mathematical Programming. Lecture 24: Discrete Optimization

Modelling linear and linear integer optimization problems An introduction

Algorithms: Lecture 12. Chalmers University of Technology

Deterministic Operations Research, ME 366Q and ORI 391 Chapter 2: Homework #2 Solutions

TRANSPORTATION & NETWORK PROBLEMS

Exercises NP-completeness

Written Exam Linear and Integer Programming (DM554)

Lecture 10: Linear programming. duality. and. The dual of the LP in standard form. maximize w = b T y (D) subject to A T y c, minimize z = c T x (P)

1 Column Generation and the Cutting Stock Problem

Computational Integer Programming. Lecture 2: Modeling and Formulation. Dr. Ted Ralphs

CSC373: Algorithm Design, Analysis and Complexity Fall 2017 DENIS PANKRATOV NOVEMBER 1, 2017

BBM402-Lecture 20: LP Duality

Lecture 15 (Oct 6): LP Duality

Part 4. Decomposition Algorithms

Introduction to optimization and operations research

Computational Integer Programming Universidad de los Andes. Lecture 1. Dr. Ted Ralphs

Learning to Branch. Ellen Vitercik. Joint work with Nina Balcan, Travis Dick, and Tuomas Sandholm. Published in ICML 2018

Integer Programming Chapter 15

A Preference-Based-Routing Example Solved by Linear Programming with Excel Solver. From Soup to Nuts. A Small 10-Agent Example

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

1 The Knapsack Problem

Integer Programming Methods LNMB

Advanced linear programming

3.3 Easy ILP problems and totally unimodular matrices

Analysis of Algorithms. Unit 5 - Intractable Problems

CS Algorithms and Complexity

1 T 1 = where 1 is the all-ones vector. For the upper bound, let v 1 be the eigenvector corresponding. u:(u,v) E v 1(u)

The Traveling Salesman Problem: An Overview. David P. Williamson, Cornell University Ebay Research January 21, 2014

Column Generation for Extended Formulations

CS 6901 (Applied Algorithms) Lecture 3

MVE165/MMG631 Linear and integer optimization with applications Lecture 5 Linear programming duality and sensitivity analysis

Operations Research: Introduction. Concept of a Model

Integer programming: an introduction. Alessandro Astolfi

Section Notes 8. Integer Programming II. Applied Math 121. Week of April 5, expand your knowledge of big M s and logical constraints.

Integer and Combinatorial Optimization: The Cut Generation LP

Linear and Integer Programming - ideas

The Dual Simplex Algorithm

Algorithm Design Strategies V

Review Questions, Final Exam

Lecture 2: Scheduling on Parallel Machines

Linear Programming. Scheduling problems

is called an integer programming (IP) problem. model is called a mixed integer programming (MIP)

Linear Programming. Formulating and solving large problems. H. R. Alvarez A., Ph. D. 1

Transcription:

MTHSC 4420 Advanced Mathematical Programming Homework 2 Megan Bryant October 30, 2013 1. Use Dijkstra s algorithm to solve the shortest path problem depicted below. For each iteration, list the node you mark permanent and the label and predecessor updates for each adjacent node. Count the total number of distance updates. Table 1: Dijkstra s Algorithm Node Step 1 Step 2 Step 3 Step4 Step 5 Step 6 1 0 2 2 3 8 2+5 = 7 2 + 3 + 1 = 6 4 3 + 2 = 5 5 8 + 0 = 8 8 6 2 + 3 + 6 = 11 11 11 2. Consider this uncapacitated facility location problem with five potential locations. The fixed costs for opening facilities at each location are f = (4, 3, 4, 4, 7). The costs for satisfying the demand for client i (row) from location j (column) is given by c ij where 12 13 6 0 1 8 4 9 1 2 C = 2 6 6 0 1 3 5 2 1 8. 8 0 5 10 8 2 0 3 4 1 1

(a) Formulate this problem as an AMPL model using the aggregated form of the fixed-charge constraint (that clients be served only from open facilities). Solve the LP relaxation (with nonnegative location variables instead of binary) and report your solution and objective function value. Original Aggregate LP: Let N = {1, 2, 3, 4, 5} be the set of locations. Let M = {1, { 2, 3, 4, 5} be the set of clients. 1 if location j serves client i Let x ij = j N, i M. { 1 if location j is opened Let y j = j N. Minimize: f j y j + Subject to: x ij = 1, i M x ij 5y j, j N i M i M x ij {0, 1}, i M, j N y j {0, 1}, j N c ij x ij Original Aggregate LP AMPL Model param locations = 5; param clients = 6; param costs{i in 1..clients, j in 1..locations}; param fixed_costs{j in 1..locations}; var x{i in 1..clients,j in 1..locations} binary; #1 if client i is served by location j var y{j in 1..locations} binary; #1 if location j is opened minimize Operating_Costs: sum{j in 1..locations}fixed_costs[j]*y[j] + sum{i in 1..clients, j in 1..locations}costs[i,j]*x[i,j]; #Minimizing the total operating costs of opening 2

a location and servicing a client from a location subject to Clients_Serviced {i in 1..clients}: sum{j in 1..locations} x[i,j] = 1; #Ensures that each client is serviced subject to Available_Locations {j in 1..locations}: sum{i in 1..clients} x[i,j] <= y[j] * clients; #Ensures that clients can only be serviced from open locations Data param costs : 1 2 3 4 5 := 1 12 13 6 0 1 2 8 4 9 1 2 3 2 6 6 0 1 4 3 5 2 1 8 5 8 0 5 10 8 6 2 0 3 4 1; param fixed_costs := 1 4 2 3 3 4 4 4 5 7; Relaxed Aggregate LP: Let N = {1, 2, 3, 4, 5} be the set of locations. Let M = {1, { 2, 3, 4, 5} be the set of clients. 1 if location j serves client i Let x ij = j N, i M. { 1 if location j is opened Let y j = j N. Minimize: Subject to: x ij = 1, i M f j y j + 5 x ij 6y j, j N i 1 i M 0 x ij 1, i M, j N 0 y j 1, j N c ij x ij Relaxed Aggregate LP AMPL 3

Model param locations = 5; param clients = 6; param costs{i in 1..clients, j in 1..locations}; param fixed_costs{j in 1..locations}; var x{i in 1..clients,j in 1..locations} binary; #1 if client i is served by location j var y{j in 1..locations} binary; #1 if location j is opened minimize Operating_Costs: sum{j in 1..locations}fixed_costs[j]*y[j] + sum{i in 1..clients, j in 1..locations}costs[i,j]*x[i,j]; #Minimizing the total operating costs of opening a location and servicing a client from a location subject to Clients_Serviced {i in 1..clients}: sum{j in 1..locations} x[i,j] = 1; #Ensures that each client is serviced subject to Available_Locations {j in 1..locations}: sum{i in 1..clients} x[i,j] <= y[j] * clients; #Ensures that clients can only be serviced from open locations option relax_integrality 1; #Relaxes the integrality constraints Data param costs : 1 2 3 4 5 := 1 12 13 6 0 1 2 8 4 9 1 2 3 2 6 6 0 1 4 3 5 2 1 8 5 8 0 5 10 8 6 2 0 3 4 1; param fixed_costs := 1 4 2 3 3 4 4 4 5 7; Relaxed Aggregated LP Solution: 4

ampl: model relaxedproblem2mod.mod; ampl: data relaxedproblem2dat.dat; ampl: option solver gurobi; ampl: solve; Gurobi 5.5.0: optimal solution; objective 5.666666667 (b) Formulate this problem as an AMPL model using the disaggregated form of the fixed-charge constraint. Solve the LP relaxation and report your solution and objective function value. Original Disaggregate LP: Let N = {1, 2, 3, 4, 5} be the set of locations. Let M = {1, { 2, 3, 4, 5} be the set of clients. 1 if location j serves client i Let x ij = j N, i M. { 1 if location j is opened Let y j = j N. Minimize: f j y j + Subject to: x ij = 1, i M i M x ij y j, i M, j N x ij {0, 1}, i M, j N y j {0, 1}, j N c ij x ij Original Disaggregate LP AMPL Model param locations = 5; param clients = 6; param costs{i in 1..clients, j in 1..locations}; param fixed_costs{j in 1..locations}; var x{i in 1..clients,j in 1..locations} binary; #1 if client i is served by location j var y{j in 1..locations} binary; #1 if location j is opened minimize Operating_Costs: sum{j in 1..locations}fixed_costs[j]*y[j] + sum{i in 1..clients, j in 1..locations}costs[i,j]*x[i,j]; 5

#Minimizing the total operating costs of opening a location and servicing a client from a location subject to Clients_Serviced {i in 1..clients}: sum{j in 1..locations} x[i,j] = 1; #Ensures that each client is serviced subject to Available_Locations {i in 1..clients, j in 1..locations}: x[i,j] <= y[j]; #Ensures that clients can only be serviced from open locations Data param costs : 1 2 3 4 5 := 1 12 13 6 0 1 2 8 4 9 1 2 3 2 6 6 0 1 4 3 5 2 1 8 5 8 0 5 10 8 6 2 0 3 4 1; param fixed_costs := 1 4 2 3 3 4 4 4 5 7; Relaxed Disaggregate LP: Let N = {1, 2, 3, 4, 5} be the set of locations. Let M = {1, { 2, 3, 4, 5} be the set of clients. 1 if location j serves client i Let x ij = j N, i M. { 1 if location j is opened Let y j = j N. Minimize: f j y j + Subject to: x ij = 1, i M x ij y j, i M, j N x ij 0, i M, j N y j 0, j N i M c ij x ij Relaxed Disaggregate LP AMPL Model 6

param locations = 5; param clients = 6; param costs{i in 1..clients, j in 1..locations}; param fixed_costs{j in 1..locations}; var x{i in 1..clients,j in 1..locations} binary; #1 if client i is served by location j var y{j in 1..locations} binary; #1 if location j is opened minimize Operating_Costs: sum{j in 1..locations}fixed_costs[j]*y[j] + sum{i in 1..clients, j in 1..locations}costs[i,j]*x[i,j]; #Minimizing the total operating costs of opening a location and servicing a client from a location subject to Clients_Serviced {i in 1..clients}: sum{j in 1..locations} x[i,j] = 1; #Ensures that each client is serviced subject to Available_Locations {i in 1..clients, j in 1..locations}: x[i,j] <= y[j]; #Ensures that clients can only be serviced from open locations option relax_integrality 1; #Relaxes the integrality conditions Data param costs : 1 2 3 4 5 := 1 12 13 6 0 1 2 8 4 9 1 2 3 2 6 6 0 1 4 3 5 2 1 8 5 8 0 5 10 8 6 2 0 3 4 1; param fixed_costs := 1 4 2 3 3 4 4 4 5 7; Relaxed Disaggregate LP Solution: ampl: model relaxedproblem3mod.mod; 7

ampl: data relaxedproblem3dat.dat; ampl: option solver gurobi; ampl: solve; Gurobi 5.5.0: optimal solution; objective 9 6 simplex iterations (c) Solve the original IP of each of your models (with binary location variables) and compare the solutions with each other and with the respective relaxation solutions. Original Aggregate LP Solution: ampl: model originalproblem2mod.mod; ampl: data originalproblem2dat.dat; ampl: option solver gurobi; ampl: solve; Gurobi 5.5.0: optimal solution; objective 9 9 simplex iterations Original Disaggregated LP Solution: ampl: model originalproblem3mod.mod; ampl: data originalproblem3dat.dat; ampl: option solver gurobi; ampl: solve; Gurobi 5.5.0: optimal solution; objective 9 12 simplex iterations The relaxed aggregate LP had a solution of 5 2 3 and the relaxed disaggregate LP had a solution of 9. Comparing these to both the original aggregate and original disaggregate solutions of 9, we see that the relaxed disaggregate LP had a better bound and, in fact, found the optimal solution. 3. The QED Company must draw up a production program for the next nine weeks. Jobs last several weeks and once started must be carried out without interruption. During each week, a certain number of skilled workers are required to work full time on the job. Thus, if job i lasts p i weeks, l iu workers are required in week u for u = 1, 2,..., p i. The total number of workers available in week t is L t. Typical job data is shown below. 8

Week Job Length 1 2 3 4 1 3 2 3 1 2 2 4 5 3 4 2 4 1 5 4 4 3 4 2 2 5 3 9 2 3 (a) Formulate the problem of finding a feasible schedule as an IP. l iu : number of workers required in the u-th week of doing job i L t : number of workers available in week t p i : number of weeks to complete job i IP Feasible Solution: Let I = {1, 2, 3, 4, 5} be the set of all jobs Let T = {1,, 9} be the set of all weeks Let Y i = {t : (t + pi 1) T } be the set of possible starting weeks for { job i 1 if job i starts in week t Let x it = i I, t Y i. Let w t be the number of workers used in week t T x it = 1, i I t Y i w t = l i(t u+1) x iu, t T i I u Y i :u t<(u+p i ) w t L t, t T x it {0, 1}, i I, t Y i (b) Formulate and solve when the objective is to minimize the maximum number of workers used during any of the nine weeks. l iu : number of workers required in the u-th week of doing job i L t : number of workers available in week t p i : number of weeks to complete job i IP Program: Let I = {1, 2, 3, 4, 5} be the set of all jobs Let T = {1,, 9} be the set of all weeks 9

Let Y i = {t : (t + pi 1) T } be the set of possible starting weeks for { job i 1 if job i starts in week t Let x it = i I, t Y i. Let w t be the number of workers used in week t T Let z = maximum number of workers in any single week Minimize: z Subject to: x it = 1, i I t Y i w t = l i(t u+1) x iu, t T i I u Y i:u t (u+p i ) w t L t, t T w t z, t T x it {0, 1}, i I, t Y i IP AMPL Code Model param jobs = 5; param total_weeks = 9; param max_job_length = 4; param max_workers; param job_workers{i in 1..jobs, j in 1..max_job_length}; param job_length{i in 1..jobs}; var x{i in 1..jobs, t in 1..total_weeks} binary; #1 if job i starts in week t,otherwise var M; set possible_start_weeks{i in 1..jobs}:= {t in 1..total_weeks: 1 <= t + job_length[i] <= total_weeks}; set active_weeks{i in 1..jobs,t in possible_start_weeks[i]}:= {u in possible_start_weeks[i]:u <= t < u + job_length[i]}; minimize Max_Workers_Week: M; subject to M_def {t in 1..total_weeks}: M >= sum{i in 1..jobs, u in 1..max_job_length}x[i,t]*job_workers[i,u]; subject to Active_Job {i in 1..jobs}: sum{t in possible_start_weeks[i]}x[i,t] = 1; 10

#Ensure that every job is completed #subject to Workers_Used {t in 1..total_weeks}: #sum{i in 1..jobs, u in active_weeks[i,t]} job_workers[i,t-u+1]*x[i,u] <= max_workers[t]; #Ensure that the number of workers used in week t is less than the number of workers available in week t subject to Min_Max_Workers_Week{t in 1..total_weeks}: sum{i in 1..jobs, u in 1..max_job_length}job_workers[i,u]*x[i,u] <= M; #Minimizes the maximum number of workers per week Data param job_workers: 1 2 3 4 := 1 2 3 1 0 2 2 4 5 0 3 2 4 1 5 4 3 4 2 2 5 9 2 3 0; param job_length := 1 3 2 2 3 4 4 4 5 3; IP AMPL Solution ampl: model problem3bmod.mod; ampl: data problem3bdat.dat; ampl: option solver gurobi; ampl: solve; Gurobi 5.5.0: optimal solution; objective 14 40 simplex iterations plus 2 simplex iterations for intbasis (c) Formulate and solve with the requirement that Job 1 must start at least two weeks before job 3. l iu : number of workers required in the u-th week of doing job i L t : number of workers available in week t p i : number of weeks to complete job i IP Program: Let I = {1, 2, 3, 4, 5} be the set of all jobs Let T = {1,, 9} be the set of all weeks 11

Let Y i = {t : (t + pi 1) T } be the set of possible starting weeks for { job i 1 if job i starts in week t Let x it = i I, t Y i. Let w t be the number of workers used in week t T Maximize: x it i T t Y i Subject to: x it = 1, i I t Y i w t = l i(t u+1) x iu, t T i I u Y i:u t (u+p i ) w t L t, t T t 1 x 1u x 3t, t = 3,, 9 u=1 x 31 = x 32 = 0 x it {0, 1}, i I, t Y i IP AMPL Code Model param jobs = 5; param total_weeks = 9; param max_job_length = 4; param max_workers; param job_workers{i in 1..jobs, j in 1..max_job_length}; param job_length{i in 1..jobs}; var x{i in 1..jobs, t in 1..total_weeks} binary; #1 if job i starts in week t,otherwise var M; set possible_start_weeks{i in 1..jobs}:= {t in 1..total_weeks: 1 <= t + job_length[i set active_weeks{i in 1..jobs,t in possible_start_weeks[i]}:= {u in possible_start_w minimize Job1_Job3{i in 1..jobs}: sum{t in 1..total_weeks,u in possible_start_weeks[i]}x[i,t]; subject to Active_Job {i in 1..jobs}: sum{t in possible_start_weeks[i]}x[i,t] = 1; #Ensure that every job is completed #subject to Min_Max_Workers_Week{t in 1..total_weeks}: 12

#sum{i in 1..jobs, u in 1..max_job_length}job_workers[i,u]*x[i,u] <= M; #Minimizes the maximum number of workers per week subject to Job1_bigger_Job3{t in 3..total_weeks}: sum{u in 1..t-1}x[1,u] >= x[3,t]; subject to Job_3: x[3,1]-x[3,2]=0; #Saying job 3 cannot start in weeks 1 or 2 Data param job_workers: 1 2 3 4 := 1 2 3 1 0 2 2 4 5 0 3 2 4 1 5 4 3 4 2 2 5 9 2 3 0; param job_length := 1 3 2 2 3 4 4 4 5 3; IP AMPL Solution ampl: model problem3cmod.mod; ampl: data problem3cdat.dat; ampl: option solver gurobi; ampl: solve; Gurobi 5.5.0: optimal solution; objective 6 Objective = Job1_Job3[1] (d) Formulate and solve with the requirement that Job 4 must start no later than one week after Job 5. l iu : number of workers required in the u-th week of doing job i L t : number of workers available in week t p i : number of weeks to complete job i IP Program: Let I = {1, 2, 3, 4, 5} be the set of all jobs Let T = {1,, 9} be the set of all weeks Let Y i = {t : (t + pi 1) T } be the set of possible starting weeks for job i 13

{ 1 if job i starts in week t Let x it = i I, t Y i. Let w t be the number of workers used in week t T Maximize: x it i T t Y i Subject to: x it = 1, i I t Y i w t = l i(t u+1) x iu, t T i I u Y i:u t (u+p i ) w t L t, t T t+1 x 4u x 5t, t = 1,, 8 u=1 x it {0, 1}, i I, t Y i IP AMPL Code Model param jobs = 5; param total_weeks = 9; param max_job_length = 4; param max_workers; param job_workers{i in 1..jobs, j in 1..max_job_length}; param job_length{i in 1..jobs}; var x{i in 1..jobs, t in 1..total_weeks} binary; #1 if job i starts in week t,otherwise var M; set possible_start_weeks{i in 1..jobs}:= {t in 1..total_weeks: 1 <= t + job_length[i set active_weeks{i in 1..jobs,t in possible_start_weeks[i]}:= {u in possible_start_w minimize Job4_Job5{i in 1..jobs}: sum{t in 1..total_weeks,u in possible_start_weeks[i]}x[i,t]; subject to Active_Job {i in 1..jobs}: sum{t in possible_start_weeks[i]}x[i,t] = 1; #Ensure that every job is completed #subject to Min_Max_Workers_Week{t in 1..total_weeks}: #sum{i in 1..jobs, u in 1..max_job_length}job_workers[i,u]*x[i,u] <= M; #Minimizes the maximum number of workers per week 14

subject to Job4_bigger_Job5{t in 1..(total_weeks-1)}: sum{u in 1..(t+1)}x[4,u] >= x[5,t]; Data param job_workers: 1 2 3 4 := 1 2 3 1 0 2 2 4 5 0 3 2 4 1 5 4 3 4 2 2 5 9 2 3 0; param job_length := 1 3 2 2 3 4 4 4 5 3; IP AMPL Solution ampl: model problem3dmod.mod; ampl: data problem3ddat.dat; ampl: option solver gurobi; ampl: solve; Gurobi 5.5.0: optimal solution; objective 6 Objective = Job4_Job5[1] (e) Formulate and solve with the requirement that Jobs 1 and 2 both require the same machine and cannot be carried out simultaneously. (Hint: This means that either Job 1 must complete before Job 2 starts or Job 2 must complete before Job 1 starts.) l iu : number of workers required in the u-th week of doing job i L t : number of workers available in week t p i : number of weeks to complete job i IP Program: Let I = {1, 2, 3, 4, 5} be the set of all jobs Let T = {1,, 9} be the set of all weeks Let Y i = {t : (t + pi 1) T } be the set of possible starting weeks for { job i 1 if job i starts in week t Let x it = i I, t Y i. Let w t be{ the number of workers used in week t T 1 if job i is active in week t Let a it = i I 15

Maximize: x it i T t Y i Subject to: x it = 1, i I t Y i w t = l i(t u+1) x iu, t T i I w t L t, t T a 1t a 2t u Y i:u t (u+p i ) max{1,(t p 1 +1)} u=1 max{1,(t p 2 +1)} u=1 a 1t + a 2t 1, t T x it {0, 1}, i I, t Y i IP AMPL Code Model x 1u, t T x 2u, t T param jobs = 5; param total_weeks = 9; param max_job_length = 4; param max_workers; param job_workers{i in 1..jobs, j in 1..max_job_length}; param job_length{i in 1..jobs}; param m1{t in 1..total_weeks}= max(1,t-job_length[1]+1); param m2{t in 1..total_weeks}= max(1,t-job_length[2]+1); var x{i in 1..jobs, t in 1..total_weeks} binary; #1 if job i starts in week t,otherwise var a{i in 1..jobs, t in 1..total_weeks} binary; set possible_start_weeks{i in 1..jobs}:= {t in 1..total_weeks: 1 <= t + job_length[i set active_weeks{i in 1..jobs,t in possible_start_weeks[i]}:= {u in possible_start_w minimize Job1_Job3{i in 1..jobs}: sum{t in 1..total_weeks,u in possible_start_weeks[i]}x[i,t]; subject to Active_Job {i in 1..jobs}: sum{t in possible_start_weeks[i]}x[i,t] = 1; #Ensure that every job is completed #subject to Min_Max_Workers_Week{t in 1..total_weeks}: #sum{i in 1..jobs, u in 1..max_job_length}job_workers[i,u]*x[i,u] <= M; #Minimizes the maximum number of workers per week 16

subject to Job1_Requirements{t in 1..total_weeks}: a[1,t]>=sum{u in 1..m1[t]}x[1,u]; subject to Job2_Requirements{t in 1..total_weeks}: a[2,t]>=sum{u in 1..m2[t]}x[2,u]; subject to Job1_Job2_Relation{t in 1..total_weeks}: a[1,t]+a[2,t] <= 1; Data param job_workers: 1 2 3 4 := 1 2 3 1 0 2 2 4 5 0 3 2 4 1 5 4 3 4 2 2 5 9 2 3 0; param job_length := 1 3 2 2 3 4 4 4 5 3; IP AMPL Solution ampl: model problem3emod.mod; ampl: data problem3edat.dat; ampl: option solver gurobi; ampl: solve; Gurobi 5.5.0: infeasible No primal variables returned. Objective = Job1_Job3[1] 4. The 0-1 knapsack problem is NP -complete. (a) Formulate the decision form of the 0-1 knapsack problem. LetN = {1,, N} be the set of possible items Let w k = the weight of each type-k item, k N Let r k = the value associated with each type-k item, k N Let c = the { weight capacity of the knapsack 1 if item k is packed Let x k = k N. Is there an x such that, 17

N r k x k v k=1 N w k x k c k=1 x k {0, 1} (b) The 2-PARTITION problem is specified by n positive integers (a 1, a 2,..., a n ). The problem is to find a subset S N = {1, 2,..., n} such that a j = j S \S or prove that it is impossible. Show that 2-PARTITION is polynomially reducible to 0-1 KNAPSACK. Does this imply that 2- PARTITION is NP -complete? LetN = {1,, N} be the set of possible items Let w k = the weight of each type-k item, k N Let r k = the value associated with each type-k item, k N Let c = the { weight capacity of the knapsack 1 if item k is packed Let x k = k N. Is there an x such that, N w k c k=1 N r k v k=1 x k {0, 1} Which implies, a j t a j t Therefore, we get the following, Reduction LP Model a j 18

a j = t This does not necessarily imply that 2-partition is NP-Complete. It would be NP-Complete if the 0 1 knapsack problem is also polynomially reducible to 2-partition. 5. The problem SET COVERING is NP -complete. Show that SET COV- ERING is polynomially reducible to the uncapacitated facility location problem (UFL). (Hint: Think of UFL as minimizing the cost of selecting a subset S of locations, where the cost is given by C(S) = n i=1 min c ij + f j. j S j S That is, think about both problems as problems involving sets rather than trying to think about the integer programming formulations. Basic IP for Set Covering: Let N = {1,, n} Let M = {{1,, m} 1 if activity j is selected Let x j =, j N. Let d j = cost { of activity j N. 1 if activity j covers requirement i Let y i j =, i M. Minimize: d j x j Subject to: y ij x j 1, i M. x j {0, 1}, j N. Basic IP for UFL: Let N = {1,, n} Let M = {1,, m} 19

Let f i be the fixed cost of opening facility i Let c ij be { the cost of service from facility j to facility i 1 if facility j is opened Let x j =, j N. { 1 if facility i is served by facility j Let a ij =, j N. Minimize: f i x i + i M Subject to: a ij = 1, i M c ij a ij a ij a j, i M, j N a ij, y ij {0, 1}, i M, j N Let activity j correspond to facility j such that all clients in the set S j M. Let F i N be the subset of locations that can serve client i. Let d j, the cost of activity j, be the cost f i of opening facility j Let c ij = 0, { for all i N, j M 1 if i S j Let a ij =, j N. { 1 if facilityiis satisfied byj Let b ij =, j N. Reduction LP Model: Minimize: f i x i + i M c ij x ij = Subject to: j F i b ij = 1, i M b ij, x j {0, 1}, i M, j N f i x i 20