Download Linear Programming Integer Programming Arne Andersson Dept of

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Linear Programming
Integer Programming
Arne Andersson
Dept of Information
Technology
Uppsala University
I Definitions, motivation
Institutionen för informationsteknologi | www.it.uu.se
Basic Mathemathical Formulation
Maximize
expression
subject to
constraints.
Institutionen för informationsteknologi | www.it.uu.se
Basic Mathemathical Formulation
LP (Linear Programming)
Maximize / minimize
linear expression
subject to
linear constraints.
IP (Integer Programming): require that all variables are integers
MIP (Mixed Integer Programming): require that some variables are
integers
Institutionen för informationsteknologi | www.it.uu.se
maximize
3 x1 + x2
3 x1 + x2 = c
x1 = 8
subject to
x1 + 2 x2 ≤ 10
x1 ≤ 8
x1 , x2 ≥ 0
Institutionen för informationsteknologi | www.it.uu.se
x1 + 2 x2 = 10
Example: Maximum Flow
A
12
B
20
C
1
10
7
D
4
5
E
F
4
G
11
H
I
12
Maximize
flow out from D (= flow into G)
subject to
- capacity per edge
- flow-in = flow-out for each vertex
Institutionen för informationsteknologi | www.it.uu.se
12
J
4
Example (IP): A seller tries to
Maximize
income
subject to
bid constraints.
Institutionen för informationsteknologi | www.it.uu.se
Example 1
Institutionen för informationsteknologi | www.it.uu.se
Example 1
•Column A contains four bids on commodities 1, 2, 3, 4.
We denote these bids as: A1, A2, A3, A4.
• In the same way,column B contains three bids: B1, B2, B4.
• Columns C, D, E contains one combinatorial bid each, denoted C,D,E.
In order to apply Integer Programming, we define one binary variable per bid:
• A1 is 1 if bid A1 wins, otherwise A1 is 0.
• A2 is 1 of bid A2 wins, otherwise A2 is 0.
• etc
We can now express the income from bid A1 as
100 * A1
i.e. if A1 = 1 the income from bid A1 is 100, otherwise the income is 0.
Institutionen för informationsteknologi | www.it.uu.se
Example 1
Maximize
100 A1 + 103 A2 + 100 A3 + 105 A4
+ 102 B1 + 99 B2 + 106 B4 + 200 C + 205 D + 305 E
subject to
A1 + B1 + C
=1
A2 + B2
+D+E=1
A3
+D+E=1
A4 + B4 + C
+E=1
(only one bid can win Commodity 1)
(only one bid can win Commodity 2)
(only one bid can win Commodity 3)
(only one bid can win Commodity 4)
Institutionen för informationsteknologi | www.it.uu.se
Example 1
Optimal solution:
B1 = 1, B4 = 1, D= 1,
all other variables are 0.
Income: 413.
Maximize
100 A1 + 103 A2 + 100 A3 + 105 A4
+ 102 B1 + 99 B2 + 106 B4 + 200 C + 205 D + 305 E
subject to
A1 + B1 + C
=1
A2 + B2
+D+E=1
A3
+D+E=1
A4 + B4 + C
+E=1
(only one bid can win Commodity 1)
(only one bid can win Commodity 2)
(only one bid can win Commodity 3)
(only one bid can win Commodity 4)
Institutionen för informationsteknologi | www.it.uu.se
Example 2
Same bids.
what is my best
income if I sell only
three of the four
commodities?
Institutionen för informationsteknologi | www.it.uu.se
Example 2
Same bids.
what is my best
income if I sell only
three of the four
commodities?
Maximize
100 A1 + 103 A2 + 100 A3 + 105 A4
+ 102 B1 + 99 B2 + 106 B4 + 200 C + 205 D + 305 E
subject to
A1 + B1 + C
=1
A2 + B2
+D+E=1
A3
+D+E=1
A4 + B4 + C
+E=1
(only one bid can win Commodity 1)
(only one bid can win Commodity 2)
(only one bid can win Commodity 3)
(only one bid can win Commodity 4)
We add one variable per commodity...
Institutionen för informationsteknologi | www.it.uu.se
Example 2
Same bids.
what is my best
income if I sell only
three of the four
commodities?
Maximize
100 A1 + 103 A2 + 100 A3 + 105 A4
+ 102 B1 + 99 B2 + 106 B4 + 200 C + 205 D + 305 E
subject to
A1 + B1 + C
= x1
A2 + B2
+ D + E = x2
A3
+ D + E = x3
A4 + B4 + C
+ E = x4
(x1 = 1 only if Commodity 1 is sold)
(x2 = 1 only if Commodity 2 is sold)
(x2 = 1 only if Commodity 2 is sold)
(x2 = 1 only if Commodity 2 is sold)
We add one variable per commodity...
...and one equation telling that 3 are sold
Institutionen för informationsteknologi | www.it.uu.se
Example 2
Same bids.
what is my best
income if I sell only
three of the four
commodities?
Maximize
100 A1 + 103 A2 + 100 A3 + 105 A4
+ 102 B1 + 99 B2 + 106 B4 + 200 C + 205 D + 305 E
subject to
A1 + B1 + C
= x1
A2 + B2
+ D + E = x2
A3
+ D + E = x3
A4 + B4 + C
+ E = x4
X1 + x2 + x3 + x4 = 3
(x1 = 1 only if Commodity 1 is sold)
(x2 = 1 only if Commodity 2 is sold)
(x2 = 1 only if Commodity 2 is sold)
(x2 = 1 only if Commodity 2 is sold)
We add one variable per commodity...
...and one equation telling that only 3 are sold
Institutionen för informationsteknologi | www.it.uu.se
Example 2
Same bids.
what is my best
income if I sell only
three of the four
commodities?
Maximize
100 A1 + 103 A2 + 100 A3 + 105 A4
+ 102 B1 + 99 B2 + 106 B4 + 200 C + 205 D + 305 E
subject to
A1 + B1 + C
= x1
A2 + B2
+ D + E = x2
A3
+ D + E = x3
A4 + B4 + C
+ E = x4
X1 + x2 + x3 + x4 = 3
(x1 = 1 only if Commodity 1 is sold)
(x2 = 1 only if Commodity 2 is sold)
(x2 = 1 only if Commodity 2 is sold)
(x2 = 1 only if Commodity 2 is sold)
We add one variable per commodity...
...and one equation telling that only 3 are sold
Institutionen för informationsteknologi | www.it.uu.se
II Techniques
Institutionen för informationsteknologi | www.it.uu.se
Techniques
3 x1 + x2 = c
x1 = 8
Simplex Algorithm
Solve LP by traversing the surface
Interior Point Algorithms
Solve LP by searching the interior
x1 + 2 x2 = 10
Slack Variables
Change each constraint from inequality to equality by adding one extra
variable
Relaxation
Solve an IP (or MIP) by
(1) solving the corresoinding LP
(2) Use techniques to ”round” the resulting variables to integers
Institutionen för informationsteknologi | www.it.uu.se
Duality
Institutionen för informationsteknologi | www.it.uu.se
Observation
3 x1 + x2 = c
x1 = 8
x1 + 2 x2 = 10
Any feasible sulution is a lower bound on the objective function
Can we find an upper bound?
Yes, by finding a feasible solution to the dual problem...
Institutionen för informationsteknologi | www.it.uu.se
maximize
3 x1 + x2
3 x1 + x2 = c
x1 = 8
subject to
x1 + 2 x2 ≤ 10
x1 ≤ 8
x1 , x2 ≥ 0
Institutionen för informationsteknologi | www.it.uu.se
x1 + 2 x2 = 10
maximize
3 x1 + x2
3 x1 + x2 = c
x1 = 8
subject to
x1 + 2 x2 ≤ 10
x1 ≤ 8
x1 + 2 x2 = 10
x1 , x2 ≥ 0
Observation on upper bound on solution:
if
3 x1 + x2 ≤ y1 ( x1 + 2 x2 ) + y 2 x1
then
3 x1 + x2 ≤ 10 y1 + 8 y2
Institutionen för informationsteknologi | www.it.uu.se
maximize
3 x1 + x2
subject to
x1 + 2 x2 ≤ 10
minimize
10 y1 + 8 y2
Dual problem:
subject to
y1 + y2 ≥ 3
x1 ≤ 8
2 y1 ≥ 1
x1 , x2 ≥ 0
y1 , y2 ≥ 0
Observation on upper bound on solution:
if
3 x1 + x2 ≤ y1 ( x1 + 2 x2 ) + y 2 x1
then
3 x1 + x2 ≤ 10 y1 + 8 y2
Institutionen för informationsteknologi | www.it.uu.se
Another example
minimize
7 x1 + x2 + 5 x3
subject to
x1 − x2 + 3 x3 ≥ 10
5 x1 + 2 x2 − x3 ≥ 6
x1 , x2 , x3 ≥ 0
Institutionen för informationsteknologi | www.it.uu.se
maximize
Dual problem:
10 y1 + 6 y2
subject to
y1 − 5 y2 ≤ 7
− y1 + 2 y2 ≤ 1
3 y1 − y2 ≤ 5
y1 , y 2 ≥ 0
General picture
maximize
f (X )
subject to
g1 ( X ) ≤ a
Dual problem:
minimize
ay1 + by 2
subject to
f ( X ) ≤ y1 g1 ( X ) + y2 g 2 ( X )
g2 ( X ) ≤ b
y1 , y2 ≥ 0
X ≥0
if
f ( X ) ≤ y1 g1 ( X ) + y2 g 2 ( X )
then we have an upper bound of f(X)
f ( X ) ≤ ay1 + by 2
Institutionen för informationsteknologi | www.it.uu.se
Summary:
Linear and Integer Programming are
powerfull tools for problem solving
Maximize
expression
subject to
constraints.
Institutionen för informationsteknologi | www.it.uu.se