Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructors: Fei Fang (This Lecture) and Dave Touretzky

Similar presentations


Presentation on theme: "Instructors: Fei Fang (This Lecture) and Dave Touretzky"β€” Presentation transcript:

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


Download ppt "Instructors: Fei Fang (This Lecture) and Dave Touretzky"

Similar presentations


Ads by Google