CS 6355: Structured Prediction
Inference: Integer Linear Programs
1
Inference: Integer Linear Programs CS 6355: Structured Prediction 1 - - PowerPoint PPT Presentation
Inference: Integer Linear Programs CS 6355: Structured Prediction 1 So far in the class Thinking about structures A graph, a collection of parts that are labeled jointly, a collection of decisions Algorithms for learning Local
1
2
– An overview of what we have seen before – Combinatorial optimization – Different views of inference
– Dynamic programming, greedy algorithms, search
– Sampling
3
– The conversion is not always trivial – Allows injection of “knowledge” into the inference in the form of constraints
– Commercial solvers: CPLEX, Gurobi, etc – Specialized solvers if you know something about your problem
– Can approximate to linear programs and hope for the best
– No free lunch
4
5
the program
6
7
Item Cost/100g Vitamin Z Nutrient X Carrots 2 4 0.4 Sunflower seeds 6 10 4 Double cheeseburger 0.3 0.01 2
8
Item Cost/100g Vitamin Z Nutrient X Carrots 2 4 0.4 Sunflower seeds 6 10 4 Double cheeseburger 0.3 0.01 2
Let c, s and d denote how much of each item is purchased Minimize total cost At least 5 units of vitamin Z, At least 3 units of nutrient X, The number of units purchased is not negative such that
9
Item Cost/100g Vitamin Z Nutrient X Carrots 2 4 0.4 Sunflower seeds 6 10 4 Double cheeseburger 0.3 0.01 2
Let c, s and d denote how much of each item is purchased Minimize total cost At least 5 units of vitamin Z, At least 3 units of nutrient X, The number of units purchased is not negative such that
10
Item Cost/100g Vitamin Z Nutrient X Carrots 2 4 0.4 Sunflower seeds 6 10 4 Double cheeseburger 0.3 0.01 2
Let c, s and d denote how much of each item is purchased Minimize total cost At least 5 units of vitamin Z, At least 3 units of nutrient X, The number of units purchased is not negative
11
Item Cost/100g Vitamin Z Nutrient X Carrots 2 4 0.4 Sunflower seeds 6 10 4 Double cheeseburger 0.3 0.01 2
Let c, s and d denote how much of each item is purchased Minimize total cost At least 5 units of vitamin Z, At least 3 units of nutrient X, The number of units purchased is not negative
12
Item Cost/100g Vitamin Z Nutrient X Carrots 2 4 0.4 Sunflower seeds 6 10 4 Double cheeseburger 0.3 0.01 2
Let c, s and d denote how much of each item is purchased Minimize total cost At least 5 units of vitamin Z, At least 3 units of nutrient X, The number of units purchased is not negative
13
linear linear
14
x1 x2 x3
15
x1 x2 x3 a1x1 + a2x2 + a3x3 = b
16
x1 x2 x3 a1x1 + a2x2 + a3x3 = b Suppose we had to maximize any cTx
17
x1 x2 x3 a1x1 + a2x2 + a3x3 = b Suppose we had to maximize any cTx
c
18
x1 x2 x3 a1x1 + a2x2 + a3x3 = b Suppose we had to maximize any cTx
c
19
x1 x2 x3 a1x1 + a2x2 + a3x3 = b Suppose we had to maximize any cTx
c
20
x1 x2 x3 a1x1 + a2x2 + a3x3 = b Suppose we had to maximize any cTx
c
21
x1 x2 x3 a1x1 + a2x2 + a3x3 = b Suppose we had to maximize any cTx
These three vertices are the only possible solutions!
22
23
The constraint matrix defines a polytope that contains allowed solutions (possibly not closed)
24
One of the constraints: 𝐵"
#𝒚 ≤ 𝑐"
The constraint matrix defines a polytope that contains allowed solutions (possibly not closed)
25
One of the constraints: 𝐵"
#𝒚 ≤ 𝑐"
Points in the shaded region can are not allowed by this constraint The constraint matrix defines a polytope that contains allowed solutions (possibly not closed)
26
The constraint matrix defines a polytope that contains allowed solutions (possibly not closed) Every constraint forbids a half-space The points that are allowed form the feasible region
27
The constraint matrix defines a polytope that contains allowed solutions (possibly not closed)
28
The objective defines cost for every point in the space The constraint matrix defines a polytope that contains allowed solutions (possibly not closed)
29
The objective defines cost for every point in the space The constraint matrix defines a polytope that contains allowed solutions (possibly not closed)
30
The constraint matrix defines a polytope that contains allowed solutions (possibly not closed) The objective defines cost for every point in the space Even though all points in the region are allowed, points on the faces maximize/minimize the cost
31
Questions?
32
33
The constraint matrix defines polytope that contains allowed solutions (possibly not closed) The objective defines cost for every point in the space Only integer points allowed
34
35
36
Eg: Only points within this region are allowed
37
Eg: Only points within this region are allowed Solution can be an interior point of the constraint set defined by Ax · b Questions?
38
39
40
Maximize the score Pick exactly one label
41
Maximize the score Pick exactly one label An assignment to the z vector gives us a y
42
Maximize the score Pick exactly one label
An assignment to the z vector gives us a y Questions?
43
x1 x2 x3 y3 y2 y1 Suppose each yi can be A, B or C Introduce one decision variable for each part being assigned labels Our goal: maxy wTÁ(x1, y1) + wTÁ(y1, y2, y3) + wTÁ(x3, y2, y3) + wTÁ(x1, x2, y2)
44
x1 x2 x3 y3 y2 y1 z1A, z1B, z1C Suppose each yi can be A, B or C Introduce one decision variable for each part being assigned labels Our goal: maxy wTÁ(x1, y1) + wTÁ(y1, y2, y3) + wTÁ(x3, y1, y3) + wTÁ(x1, x2, y2)
45
x1 x2 x3 y3 y2 y1 z1A, z1B, z1C z13AA, z13AB, z13AC, z13BA, z13BB, z13BC, z13CA, z13CB, z13CC z23AA, z23AB, z23AC, z23BA, z23BB, z23BC, z23CA, z23CB, z23CC z2A, z2B, z2C Suppose each yi can be A, B or C Introduce one decision variable for each part being assigned labels Each of these decision variables is associated with a score Questions? Our goal: maxy wTÁ(x1, y1) + wTÁ(y1, y2, y3) + wTÁ(x3, y1, y3) + wTÁ(x1, x2, y2)
46
Suppose each yi can be A, B or C Introduce one decision variable for each part being assigned labels Each of these decision variables is associated with a score x1 x2 x3 y3 y2 y1 Our goal: maxy wTÁ(x1, y1) + wTÁ(y1, y2, y3) + wTÁ(x3, y1, y3) + wTÁ(x1, x2, y2)
47
Suppose each yi can be A, B or C Introduce one decision variable for each part being assigned labels Each of these decision variables is associated with a score Not all decisions can exist together. Eg: z13AB implies z1A and z3B x1 x2 x3 y3 y2 y1 Our goal: maxy wTÁ(x1, y1) + wTÁ(y1, y2, y3) + wTÁ(x3, y2, y3) + wTÁ(x1, x2, y2)
zA + zB + zC = 1
zA + zB + zC ¸ m
zA + zB + zC · m
– Convert to disjunction: ¬ zi Ç zj
– 1 – zi + zj ¸ 1 (i.e.) zj ¸ zi
48
zA + zB + zC = 1
zA + zB + zC ¸ m
zA + zB + zC · m
– Convert to disjunction: ¬ zi Ç zj
– 1 – zi + zj ¸ 1 (i.e.) zj ¸ zi
49
Generally: All Boolean formulas can be converted to constraints Exercise: Convert the toy conditional model below to an ILP by hand x1 x2 x3 y3 y2 y1
50
y2 y3 y1 y
n
…
51
How can this be written as an ILP?
52
53
54
How can this be written as an ILP?
– Even the “easy”/polynomial ones – Given an ILP, checking whether it represents a polynomial problem is intractable in general
– The representation allows us to make general statements about inference – Important: Framing/writing down the inference problem is separate from solving it
– Gurobi, CPLEX – Use an off the shelf solver only if you can’t solve your inference problem
55
– The conversion is not always trivial – Allows injection of “knowledge” into the inference in the form of constraints
– Commercial solvers: CPLEX, Gurobi, etc – Specialized solvers if you know something about your problem
– Can relax to linear programs and hope for the best
– No free lunch
56
Questions?