Download presentation
Presentation is loading. Please wait.
Published byRidwan Kartawijaya Modified over 6 years ago
1
Instructors: Fei Fang (This Lecture) and Dave Touretzky
Artificial Intelligence: Representation and Problem Solving Optimization (3): (Mixed) Integer Linear Programming / 681 Instructors: Fei Fang (This Lecture) and Dave Touretzky Wean Hall 4126 Donβt expect them to remember, just use as resource 12/8/2018
2
Nonconvex but continuous optimization Linear program
Recap Convex optimization π is a convex function and β± is a convex set Gradient descent leads to global optimum Nonconvex but continuous optimization Gradient descent leads to local optima Linear program π is a linear function and β± is a convex polytope This section: π is a linear function and β± is defined by a set of linear constraints + integer constraints min π₯ π(π₯) s.t. π₯ββ± Properties Finite options (brute force when the problem scale is small) (Often) NP-Complete Solution approach Brute force when the problem scale is small Fei Fang 12/8/2018
3
(Mixed) Integer Linear Program How to solve a MILP
Outline (Mixed) Integer Linear Program How to solve a MILP Formulate/Convert to MILP Fei Fang 12/8/2018
4
(Mixed) Integer Linear Program: Definition
A special case of non-convex optimization problem An optimization problem whose optimization objective is a linear function and feasible region is defined by a set of linear constraints + integer constraints πβ β π πΊβ β πΓπ ,ββ β π 0< π½ π§ β€π Integer Linear Program (ILP): π½ π§ =π max π₯ π π π₯ s.t. πΊπ₯β€β π₯ π ββ€,πβ π½ π§ Can be minimization Can be β₯β or =β Efficient solvers / code packages available! Fei Fang 12/8/2018
5
(Mixed) Integer Linear Program: Example
Example: Maximize Profit in Manufacturing max π₯,π¦ 30π₯+30π¦ s.t. 0.2π₯+0.5π¦β€90 4π₯+2π¦β€800 π₯β₯0,π¦β₯0 π₯,π¦ββ€ Original product can be: cloth, rope etc Price Labor Machine Product 1 $30 0.2 hour 4 hour Product 2 0.5 hour 2 hour Total <=90 <=800 Earphone Charger Fei Fang 12/8/2018
6
Binary Linear Program: Definition
Binary Linear Program (BIP): All variables are restricted to take value 0 or 1 max π₯ π π π₯ s.t. πΊπ₯β€β π₯ π β 0,1 ,βπ Fei Fang 12/8/2018
7
Binary Linear Program: Example
0-1 Knapsack Maximum weight =10 How to select items to maximize total value? Items 1 2 3 4 5 Weight 6 7 Value 9 You have a knapsack, and the maximum weight you can take is 10 Fei Fang 12/8/2018
8
Binary Linear Program: Example
0-1 Knapsack π indivisible items. Item π has weight π€ π , value π£ π . Maximum weight is π (πβ€ π π€ π ) How to pick the items to maximize total value? You have a knapsack, and the maximum weight you can take is 10 Fei Fang 12/8/2018
9
(Mixed) Integer Linear Program How to solve a MILP
Outline (Mixed) Integer Linear Program How to solve a MILP Formulate/Convert to MILP Fei Fang 12/8/2018
10
LP Relaxation LP relaxation of an MILP or BLP is the LP with the same linear constraints LP Relaxation MILP max π₯ π π π₯ s.t. πΊπ₯β€β π₯ π ββ€,πβ π½ π§ max π₯ π π π₯ s.t. πΊπ₯β€β BLP LP Relaxation max π₯ π π π₯ s.t. πΊπ₯β€β π₯ π β 0,1 ,βπ max π₯ π π π₯ s.t. πΊπ₯β€β π₯ π β[0,1] Fei Fang 12/8/2018
11
Quiz 1: LP Relaxation Let π₯ β , π β be the optimal solution and the optimal value of a MILP. Let π₯ β , π β be the optimal solution and the optimal value of the LP relaxation. Which of the following are true? A: π₯ β = π₯ β B: π β β€ π β if it is a maximization problem C: π β β€ π β if it is a minimization problem D: π β β₯ π β if it is a maximization problem E: π β β₯ π β if it is a minimization problem B,E MILP LP Relaxation max π₯ π π π₯ s.t. πΊπ₯β€β π₯ π ββ€,πβ π½ π§ max π₯ π π π₯ s.t. πΊπ₯β€β Fei Fang 12/8/2018
12
Quiz 2: (Mixed) Integer Linear Program
Which are optimal solutions? (137.5,125) (138,125) 137,125 138,124 None of above max π₯,π¦ 30π₯+30π¦ s.t. 0.2π₯+0.5π¦β€90 4π₯+2π¦β€800 π₯β₯0,π¦β₯0 π₯,π¦ββ€ 0.2π₯+0.5π¦=90 4π₯+2π¦=800 Fei Fang 12/8/2018
13
How to solve Is it sufficient to consider integer points around the corresponding LP solution? No! Solution to the MILP can be arbitrarily far from the solution of the corresponding LP (relaxing all the integer constraints) Sometimes even hard to find a feasible integer point Fei Fang 12/8/2018
14
For Binary Linear Program (BLP)
How to solve For Binary Linear Program (BLP) Discrete optimization problem NaΓ―ve approach: Enumerate all the possibilities Can apply uninformed or informed search Natural tree structure Items 1 2 3 4 5 Weight 6 7 Value 9 max 4π₯ 1 +3 π₯ 2 +6 π₯ 3 +9 π₯ 4 +5 π₯ 5 s.t. 5π₯ 1 +4 π₯ 2 +2 π₯ 3 +6 π₯ 4 +7 π₯ 5 β€10 π₯ π β{0,1} Fei Fang 12/8/2018
15
Depth-First Search for BLP
max 4π₯ 1 +3 π₯ 2 +6 π₯ 3 +9 π₯ 4 +5 π₯ 5 s.t. 5π₯ 1 +4 π₯ 2 +2 π₯ 3 +6 π₯ 4 +7 π₯ 5 β€10 π₯ π β{0,1} Fei Fang 12/8/2018
16
Recall: Informed Search
function BEST-FIRST-SEARCH (problem, EVAL-FN) returns a solution sequence inputs: problem, a problem EVAL-FN, an evaluation function Queuing-Fn β a function that orders nodes by EVAL-FN return GENERAL-SEARCH (problem, Queuing-Fn) function GREEDY-SEARCH (problem) returns a solution or failure return BEST-FIRST-SEARCH (problem, h) π΄ β search: Best-first-search with EVAL-FN π(π§)=π(π§)+ β(π§) where β(π§) is an admissible heuristic for node π§ π π§ =path cost up to node π§, β(π§)=heuristic estimate of distance to go In a minimization problem, β(π§) never overestimates the distance to go In a maximization problem, β(π§) never underestimates the value of the remaining path Optimal for tree search Fei Fang 12/8/2018
17
For Binary Linear Program (BLP)
How to solve For Binary Linear Program (BLP) Discrete optimization problem NaΓ―ve approach: Enumerate all the possibilities Can apply uninformed or informed search Natural tree structure Vanilla branch and bound (BnB)=Best-first-search with EVAL-FN π(π§)= optimal value of LP relaxation at node π§ Fei Fang 12/8/2018
18
Evaluation Function in Branch and Bound
LP relaxation at node π π max 4π₯ 1 +3 π₯ 2 +6 π₯ 3 +9 π₯ 4 +5 π₯ 5 s.t. 5π₯ 1 +4 π₯ 2 +2 π₯ 3 +6 π₯ 4 +7 π₯ 5 β€10 π₯ π β[0,1],π=1..5 π₯ 1 =0 π₯ 1 =0 π₯ 1 =1 π π π π§ = optimal value of LP relaxation at node π§ LP relaxation provides a upper bound of the objective value of any solution with a path through π§ if it is a maximization problem (lower bound if minimization) Never underestimates the real value of the whole path given the path goes through π§ for maximization problem (never overestimate the total cost for minimization) π π§ β(path value up to π§) is an admissible heuristic Fei Fang 12/8/2018
19
For Binary Linear Program (BLP)
How to solve For Binary Linear Program (BLP) Discrete optimization problem NaΓ―ve approach: Enumerate all the possibilities Can apply uninformed or informed search Natural tree structure Vanilla branch and bound (BnB)=Best-first-search with EVAL-FN π(π§)= optimal value of LP relaxation at node π§ Optimality guaranteed Fei Fang 12/8/2018
20
For Binary Linear Program (BLP)
How to solve For Binary Linear Program (BLP) Discrete optimization problem NaΓ―ve approach: Enumerate all the possibilities Can apply uninformed or informed search Natural tree structure Vanilla branch and bound (BnB)=Best-first-search with EVAL-FN π(π§)= optimal value of LP relaxation at node π§ Optimality guaranteed BnB with upper bound and lower bound (not required) Terminate early if we know the remaining nodes are not as good as a binary solution we have already found Fei Fang 12/8/2018
21
For MILP (not required)
How to solve For MILP (not required) BnB: For each integer variable, branching a node by considering π₯ π β€ π₯ π and π₯ π β₯ π₯ π where π₯ π is a non- integer value Branch and cut: use cutting planes (which are hyperplanes) to separate current non-integer solution and integer solutions Fei Fang 12/8/2018
22
How to solve Practically efficient solvers: Cplex, Gurobi, intlinprog (MATLAB), SCIP solver Fei Fang 12/8/2018
23
(Mixed) Integer Linear Program How to solve a MILP
Outline (Mixed) Integer Linear Program How to solve a MILP Formulate/Convert to MILP Fei Fang 12/8/2018
24
Constraint satisfaction problem
TWO+TWO=FOUR Fei Fang 12/8/2018
25
Constraint satisfaction problem
TWO+TWO=FOUR Variables: π₯ π , π₯ π , π₯ π , π₯ πΉ , π₯ π , π₯ π
, π 1 , π 2 , π 3 min x,c 1 s.t. π₯ π + π₯ π = π₯ π
+10 π 1 π₯ π + π₯ π + π 1 = π₯ π +10 π 2 π₯ π + π₯ π + π 2 = π₯ π +10 π 3 0+ π 3 = π₯ πΉ π₯ π , π₯ πΉ β{1,..,9} π₯ π , π₯ π , π₯ π , π₯ π
β{0,..,9} π 1 , π 2 , π 3 β{0,1} Fei Fang 12/8/2018
26
Formulate a Problem as a MILP
Sudoku Fill a 9Γ9 grid with digits so that each column, each row, and each of the nine 3Γ3 subgrids that compose the grid (also called "boxes", "blocks", or "regions") contains all of the digits from 1 to 9 Fei Fang 12/8/2018
27
Formulate a Problem as a MILP
Sudoku Variables π₯ ππ π indicate if we place number π in row π, col π π π‘ is the set of (row,col) index pairs of the π‘ π‘β groups (rows, columns, and subgrids) For example, π 1 ={ 1,1 , 1,2 ,β¦(1,9)} min π₯ 1 s.t. π₯ ππ π β 0,1 ,βπ,π,πβ{1..9} π,π β π π‘ π₯ ππ π =1 ,βπβ 1..9 ,βπ‘β{1..27} π π₯ ππ π =1 ,βπ,πβ{1..9} Fei Fang 12/8/2018
28
Formulate a Problem as a MILP
Kidney Exchange Fei Fang 12/8/2018
29
Formulate a Problem as a MILP
Kidney Exchange Given directed graph πΊ=(π,πΈ), where each node represent a patient-donor pair, and an edge β©π’,π£βͺ means donor of node π’ can give one kidney to patient of node π£ Find a set of disjoint cycles so as to maximize the number of nodes covered 6 2 1 4 5 3 7 8 Fei Fang 12/8/2018
30
Quiz 3: Kidney Exchange Given the graph below, what is the maximum number of patients that can get a kidney through kidney exchange assuming the length of each cycle should be less than or equal to 3? A: 3 B: 6 C: 7 D: 8 6 2 1 4 5 3 7 8 Fei Fang 12/8/2018
31
Formulate a Problem as a MILP
Kidney Exchange Given directed graph πΊ=(π,πΈ), where each node represent a patient-donor pair, and an edge β©π’,π£βͺ means donor of node π’ can give one kidney to patient of node π£ Find a set of disjoint cycles so as to maximize the number of nodes covered Hint: enumerate all the cycles 6 2 1 4 5 3 7 8 Fei Fang 12/8/2018
32
No queen in the same row, column and diagnal
8-Queens Problem No queen in the same row, column and diagnal π₯ ππ : whether there is a queen on row π col π max x π π π₯ ππ s.t. π₯ ππ β{0,1} π π₯ ππ β€1,βπβ{1..8} π π₯ ππ β€1, βπβ{1..8} π,π:πβπ=π π₯ ππ =1,βπβ β6,β5,β¦,5,6 π,π:π+π=π π₯ ππ =1,βπβ 2,3,β¦,14 Fei Fang 12/8/2018
33
Recall in the first lecture about optimization, we had
8-Queens Problem Recall in the first lecture about optimization, we had Can we rewrite it using only linear constraints + integer constraints? Variables π₯ π : row index of the queen in π π‘β column min x 1 s.t. π₯ π β{1β¦8} π₯ π β π₯ π ,βπ,πβ 1..8 ,πβ π π₯ π β π₯ π β πβπ ,βπ,πβ 1..8 ,πβ π Fei Fang 12/8/2018
34
8-Queens Problem min x 1 s.t. π₯ π β{1β¦8} π₯ π β π₯ π ,βπ,πβ 1..8 ,πβ π
π₯ π β π₯ π β πβπ ,βπ,πβ 1..8 ,πβ π Convert constraints (We omit the range of index below) min x 1 s.t. π₯ π β{1β¦8} π₯ π β₯ π₯ π +1 or π₯ π β€ π₯ π β1, | π₯ π β π₯ π |β₯|πβπ|+1 or | π₯ π β π₯ π |β€|πβπ|β1 Fei Fang 12/8/2018
35
Formulate a Problem as a MILP
8-Queens Problem Introduce variables π¦ ππ + , π¦ ππ β , set π΅=100 min x,π¦,π§ 1 s.t. π₯ π β{1β¦8} π₯ π β( π₯ π +1)+π΅ π¦ ππ + β₯0 π₯ π β( π₯ π β1)βπ΅ π¦ ππ β β€0 π¦ ππ + + π¦ ππ β β€1 π¦ ππ + , π¦ ππ β β{0,1} | π₯ π β π₯ π |β₯|πβπ|+1 or | π₯ π β π₯ π |β€|πβπ|β1 min x 1 s.t. π₯ π β{1β¦8} π₯ π β₯ π₯ π +1 or π₯ π β€ π₯ π β1 | π₯ π β π₯ π |β₯|πβπ|+1 or | π₯ π β π₯ π |β€|πβπ|β1 Fei Fang 12/8/2018
36
General techniques for conversion
At-most-one constraint: At most one of the options can be chosen Add variable π₯ π β{0,1} to represent whether or not option π is chosen Add constraint π π₯ π =1 Fei Fang 12/8/2018
37
General techniques for conversion
Constraint feasibility constraint: If π¦=0, then π π₯ 1 , π₯ 2 ,β¦, π₯ π β€π Choose a large enough constant π΅ such that π π₯ 1 , π₯ 2 ,β¦, π₯ π βπ΅β€π is always satisfied (imagine π΅= +β) Add constraint π π₯ 1 , π₯ 2 ,β¦, π₯ π βπ΅π¦β€π Fei Fang 12/8/2018
38
General techniques for conversion
Alternative Constraints: π 1 π₯ 1 , π₯ 2 ,β¦, π₯ π β€ π 1 or π 2 π₯ 1 , π₯ 2 ,β¦, π₯ π β€ π 2 Introduce some large enough constants π΅ 1 , π΅ 2 such that π π π₯ 1 , π₯ 2 ,β¦, π₯ π β π΅ π β€ π π always hold Introduce binary variables π¦ 1 , π¦ 2 Add constraints π 1 π₯ 1 , π₯ 2 ,β¦, π₯ π β π΅ 1 π¦ 1 β€ π 1 π 2 π₯ 1 , π₯ 2 ,β¦, π₯ π β π΅ 2 π¦ 2 β€ π 2 π¦ 1 + π¦ 2 β€1 π¦ 1 , π¦ 2 β{0,1} Fei Fang 12/8/2018
39
General techniques for conversion
Conditional Constraints If π 1 π₯ 1 , π₯ 2 ,β¦, π₯ π > π 1 , then π 2 π₯ 1 , π₯ 2 ,β¦, π₯ π β€ π 2 Equivalent to π 1 π₯ 1 , π₯ 2 ,β¦, π₯ π β€ π 1 or π 2 π₯ 1 , π₯ 2 ,β¦, π₯ π β€ π 2 Apply techniques for alternative constraints Fei Fang 12/8/2018
40
General techniques for conversion
Bilinear term π₯π¦ where π₯β{0,1} and π¦β [ π¦ πππ , π¦ πππ₯ ] Introduce new variable π§ Add constraints π¦ πππ π₯β€π§β€ π¦ πππ₯ π₯ Fei Fang 12/8/2018
41
Summary Optimization Problems Convex Programs Mixed Integer
Linear Programs Gradient Descent Linear Programs Branch and Bound Simplex Fei Fang 12/8/2018
42
(Mixed) Integer Linear Program: Additional Resources
Textbook Applied Mathematical Programming, Chapter 9 By Bradley,Β Hax, andΒ MagnantiΒ (Addison-Wesley, 1977)Β Online course integer-programming-and-combinatorial-optimization-fall- 2009/index.htm Fei Fang 12/8/2018
43
Acknowledgment Some slides are borrowed from previous slides made by J. Zico Kolter and Ariel Procaccia Fei Fang 12/8/2018
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.