24
CSCI 573 CSCI 573 Linear and Mixed Integer Linear and Mixed Integer Programming Programming Sven Koenig Sven Koenig

CSCI 573 Linear and Mixed Integer Programming Sven Koenig

Embed Size (px)

Citation preview

Page 1: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

CSCI 573CSCI 573

Linear and Mixed Integer ProgrammingLinear and Mixed Integer Programming

Sven KoenigSven Koenig

Page 2: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

Linear Programming (LP)Linear Programming (LP)

A cement manufacturer produces two types of A cement manufacturer produces two types of cement: A and B. They cannot make more than cement: A and B. They cannot make more than 1600 kilograms a day due to a shortage of 1600 kilograms a day due to a shortage of transport vehicles. A sales contract forces them transport vehicles. A sales contract forces them to produce at least 500 kilograms of cement B to produce at least 500 kilograms of cement B per day. It takes 0.48 (0.24) minutes to make a per day. It takes 0.48 (0.24) minutes to make a kilogram of cement A (B) and the plant operates kilogram of cement A (B) and the plant operates 8 hours a day. The profit is $4 ($3) per kilogram 8 hours a day. The profit is $4 ($3) per kilogram of cement A (B). How many kilograms of cement of cement A (B). How many kilograms of cement A and B should they make to maximize their A and B should they make to maximize their profit?profit?

Page 3: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

Linear Programming (LP)Linear Programming (LP)

A = produced kg’s of cement A per dayA = produced kg’s of cement A per day

B = produced kg’s of cement B per dayB = produced kg’s of cement B per day

Maximize 4 A + 3 BMaximize 4 A + 3 B

Subject toSubject to A + B A + B ≤ 1600≤ 1600 B ≥ 500B ≥ 500 0.48 A + 0.24 B ≤ 4800.48 A + 0.24 B ≤ 480 A ≥ 0, B ≥ 0A ≥ 0, B ≥ 0

Page 4: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

Almost Linear Programming (LP)Almost Linear Programming (LP)

A cement manufacturer produces two types of A cement manufacturer produces two types of cement: A and B. They cannot make more than cement: A and B. They cannot make more than 1600 1600 bagsbags a day due to a shortage of transport a day due to a shortage of transport vehicles. A sales contract forces them to vehicles. A sales contract forces them to produce at least 500 produce at least 500 bagsbags of cement B per day. of cement B per day. It takes 0.48 (0.24) minutes to make a It takes 0.48 (0.24) minutes to make a bag bag of of cement A (B) and the plant operates 8 hours a cement A (B) and the plant operates 8 hours a day. The profit is $4 ($3) per day. The profit is $4 ($3) per bagbag of cement A of cement A (B). How many (B). How many bagsbags of cement A and B should of cement A and B should they make to maximize their profit?they make to maximize their profit?

Page 5: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixLinear Programming (LP)Linear Programming (LP)

A manufacturer produces animal feed with 2 active A manufacturer produces animal feed with 2 active ingredients and a filler ingredient. One kg of feed mix ingredients and a filler ingredient. One kg of feed mix must contain 90g of nutrient A, 50g of nutrient B, 20g of must contain 90g of nutrient A, 50g of nutrient B, 20g of nutrient C and 2g of nutrient D. The ingredients have the nutrient C and 2g of nutrient D. The ingredients have the following nutrient values and costs. What should be the following nutrient values and costs. What should be the amount of ingredients in one kg of feed mix to minimize amount of ingredients in one kg of feed mix to minimize cost? (The filler ingredient costs nothing.)cost? (The filler ingredient costs nothing.)

AA BB CC DD $/kg$/kg

Active Active Ingredient Ingredient 1 (g/kg)1 (g/kg)

100100 8080 4040 1010 4040

Active Active Ingredient Ingredient 2 (g/kg)2 (g/kg)

200200 150150 2020 ------ 6060

Page 6: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixLinear Programming (LP)Linear Programming (LP)

A = kg of ingredient 1 per kg of feed mixA = kg of ingredient 1 per kg of feed mixB = kg of ingredient 2 per kg of feed mixB = kg of ingredient 2 per kg of feed mixMinimize 40 A + 60 BMinimize 40 A + 60 BSubject toSubject to A + B A + B ≤ 1≤ 1 100 A + 200 B 100 A + 200 B ≥ 90≥ 90 80 A + 150 B ≥ 5080 A + 150 B ≥ 50 40 A + 20 B ≥ 2040 A + 20 B ≥ 20 10 A ≥ 210 A ≥ 2 A ≥ 0, B ≥ 0A ≥ 0, B ≥ 0

Page 7: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixLinear Programming (LP)Linear Programming (LP)

Exactsolution:A = 0.3667B = 0.2667

Feasible region(all of these pointssatisfy the constraints)

Solution(a point in the feasibleregion that minimizes the objective function)

Page 8: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixLinear Programming (LP)Linear Programming (LP)

LPs can be solved in polynomial time.LPs can be solved in polynomial time.

In practice, one often uses variants of the In practice, one often uses variants of the simplex method (which is not guaranteed simplex method (which is not guaranteed to run in polynomial time but often runs to run in polynomial time but often runs very fast).very fast).

Page 9: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixMixed Integer Programming (MIP)Mixed Integer Programming (MIP)

What if there is a fixed cost of $15 if any of What if there is a fixed cost of $15 if any of active ingredient 2 is used?active ingredient 2 is used?

Page 10: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixMixed Integer Programming (MIP)Mixed Integer Programming (MIP)A = kg of ingredient 1 per kg of feed mixA = kg of ingredient 1 per kg of feed mixB = kg of ingredient 2 per kg of feed mixB = kg of ingredient 2 per kg of feed mixX = 1 if B > 0, 0 otherwiseX = 1 if B > 0, 0 otherwiseMinimize 40 A + 60 B + 15 XMinimize 40 A + 60 B + 15 XSubject toSubject to A + B A + B ≤ 1≤ 1 100 A + 200 B 100 A + 200 B ≥ 90≥ 90 80 A + 150 B ≥ 580 A + 150 B ≥ 5 40 A + 20 B ≥ 2040 A + 20 B ≥ 20 10 A ≥ 210 A ≥ 2 B ≤ XB ≤ X A ≥ 0, B ≥ 0, X ≥ 0A ≥ 0, B ≥ 0, X ≥ 0 X is integerX is integer

Page 11: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixMixed Integer Programming (MIP)Mixed Integer Programming (MIP)

What if they need to satisfy only three of What if they need to satisfy only three of the four nutrient constraints?the four nutrient constraints?

Page 12: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixMixed Integer Programming (MIP)Mixed Integer Programming (MIP)A = kg of ingredient 1 per kg of feed mixA = kg of ingredient 1 per kg of feed mixB = kg of ingredient 2 per kg of feed mixB = kg of ingredient 2 per kg of feed mixX1 = 1 if constraint 1 is satisfied, 0 otherwiseX1 = 1 if constraint 1 is satisfied, 0 otherwiseX2 = …X2 = …Minimize 40 A + 60 B + 15 XMinimize 40 A + 60 B + 15 XSubject toSubject to

A + B A + B ≤ 1≤ 1 100 A + 200 B 100 A + 200 B ≥ 90 X1≥ 90 X1 80 A + 150 B ≥ 5 X280 A + 150 B ≥ 5 X2 40 A + 20 B ≥ 20 X340 A + 20 B ≥ 20 X3 10 A ≥ 2 X410 A ≥ 2 X4 X1 + X2 + X3 + X4 ≥ 3X1 + X2 + X3 + X4 ≥ 3 A ≥ 0, B ≥ 0, 1 ≥ X1 ≥ 0, 1 ≥ X2 ≥ 0, 1 ≥ X3 ≥ 0, 1 ≥ X4 ≥ 0A ≥ 0, B ≥ 0, 1 ≥ X1 ≥ 0, 1 ≥ X2 ≥ 0, 1 ≥ X3 ≥ 0, 1 ≥ X4 ≥ 0 X1, X2, X3 and X4 are integerX1, X2, X3 and X4 are integer

Page 13: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixMixed Integer Programming (MIP)Mixed Integer Programming (MIP)

MIPs can likely not be solved in MIPs can likely not be solved in polynomial time (solving them is NP-hard).polynomial time (solving them is NP-hard).

Viewing MIPs as LPs and rounding Viewing MIPs as LPs and rounding variables to the closest integer can result variables to the closest integer can result in large errors.in large errors.

In practice, one often uses CPLEX, In practice, one often uses CPLEX, industrial-strength software that can solve industrial-strength software that can solve LPs and MIPs. LPs and MIPs.

Page 14: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

AppendixAppendixSource for LP and MIP MaterialSource for LP and MIP Material

This problem and many more examples This problem and many more examples can be found in the OR Notes by J. E. can be found in the OR Notes by J. E. Beasly atBeasly at

people.brunel.ac.uk/~mastjjb/jeb/or/contents.htmlpeople.brunel.ac.uk/~mastjjb/jeb/or/contents.html

Page 15: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

Assume that there are N robots in the plane at Assume that there are N robots in the plane at initial locations R1, …, RN. There are M target initial locations R1, …, RN. There are M target locations T1, …, TM in the same plane. Each locations T1, …, TM in the same plane. Each target has to be visited by at least one robot. target has to be visited by at least one robot. The robots do not need to return to their initial The robots do not need to return to their initial locations. Write a mixed integer program that locations. Write a mixed integer program that determines which robot should visit which target determines which robot should visit which target locations and in which order if the team objective locations and in which order if the team objective is to minimize the sum of the travel distances of is to minimize the sum of the travel distances of all robots.all robots.

Page 16: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

Multi-robot routing problems can be solved optimally Multi-robot routing problems can be solved optimally with Mixed Integer Programming (MIP) methods, with Mixed Integer Programming (MIP) methods, such as CPLEX:such as CPLEX:

Index sets and constants:Index sets and constants:

VVRR = = Set of robot verticesSet of robot vertices

VVTT = = Set of target verticesSet of target vertices

c(i,j) = c(i,j) = Path cost from vertex i to vertex jPath cost from vertex i to vertex j

Variables:Variables:

xxijij = = Is vertex j visited by some robot directly afterIs vertex j visited by some robot directly aftervertex i? (1 = yes, 0 = no)vertex i? (1 = yes, 0 = no)

Page 17: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

Multi-robot routing problems can be solved Multi-robot routing problems can be solved optimally with Mixed Integer Programming (MIP) optimally with Mixed Integer Programming (MIP) methods, such as CPLEX:methods, such as CPLEX:

(C1)

(C2)

(C3)

Page 18: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

Multi-robot routing problems can be Multi-robot routing problems can be solved optimally with Mixed Integer solved optimally with Mixed Integer Programming (MIP) methods, such as Programming (MIP) methods, such as CPLEX:CPLEX:

(C1) Each target vertex is entered exactly once(C1) Each target vertex is entered exactly once

(C2) Each (robot or target) vertex is left at most once(C2) Each (robot or target) vertex is left at most once

(C3) There are no subtours (= cycles)(C3) There are no subtours (= cycles)

Page 19: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

Objective onlyObjective only

Page 20: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

Objective and constraint C1 onlyObjective and constraint C1 only

(a possible solution, not necessarily the optimal one)

Page 21: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

Objective and constraints C1 and C2 onlyObjective and constraints C1 and C2 only

(a possible solution, not necessarily the optimal one)

Page 22: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

Objective and constraints C1, C2 and C3Objective and constraints C1, C2 and C3

(a possible solution, not necessarily the optimal one)

Page 23: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

The number of subtour elimination constraints The number of subtour elimination constraints (C3) is exponential in the number of targets.(C3) is exponential in the number of targets.Only small multi-robot routing problems can be Only small multi-robot routing problems can be solved optimally with MIP methods, even after solved optimally with MIP methods, even after tuning them (for example, by using cutting plane tuning them (for example, by using cutting plane techniques).techniques).

Page 24: CSCI 573 Linear and Mixed Integer Programming Sven Koenig

An AI ProblemAn AI Problem

See page 5 of “Simple Auctions with Performance Guarantees for See page 5 of “Simple Auctions with Performance Guarantees for Multi-Robot Task Allocation” by Lagoudakis et al. (IROS 2004)Multi-Robot Task Allocation” by Lagoudakis et al. (IROS 2004)idm-lab.org/bib/abstracts/Koen04i.htmlidm-lab.org/bib/abstracts/Koen04i.html