mixed integer linear programming
play

Mixed Integer Linear Programming Combinatorial Problem Solving (CPS) - PowerPoint PPT Presentation

Mixed Integer Linear Programming Combinatorial Problem Solving (CPS) Javier Larrosa Albert Oliveras Enric Rodr guez-Carbonell May 8, 2020 Mixed Integer Linear Programs A mixed integer linear program (MILP, MIP) is of the form min c


  1. Example Min obj: - x - y Subject To c1: -2 x + 2 y >= 1 c2: -8 x + 10 y <= 13 Bounds x <= 2 y <= 3 End ==================================================================== CPLEX> optimize Dual simplex - Optimal: Objective = - 4.9000000000e+00 Solution time = 0.00 sec. Iterations = 0 (0) Deterministic time = 0.00 ticks (2.71 ticks/sec) CPLEX> display solution variables x Variable Name Solution Value x 2.000000 CPLEX> display solution variables y Variable Name Solution Value y 2.900000 26 / 62

  2. Example min − x − y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 x, y ≥ 0 x, y ∈ Z y ≤ 4 y ≥ 5 x ≥ 4 x ≤ 3 y ≤ 3 y ≥ 4 x ≥ 3 x ≤ 2 y ≤ 2 y ≥ 3 27 / 62

  3. Example min − x − y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 x, y ≥ 0 x, y ∈ Z y ≤ 4 y ≥ 5 x ≥ 4 x ≤ 3 y ≤ 3 y ≥ 4 x ≥ 3 x ≤ 2 y ≤ 2 y ≥ 3 27 / 62

  4. Example Min obj: - x - y Subject To c1: -2 x + 2 y >= 1 c2: -8 x + 10 y <= 13 Bounds x <= 2 y = 3 End ==================================================================== CPLEX> optimize Bound infeasibility column ’x’. Presolve time = 0.00 sec. (0.00 ticks) Presolve - Infeasible. Solution time = 0.00 sec. Deterministic time = 0.00 ticks (1.12 ticks/sec) 28 / 62

  5. Example min − x − y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 x, y ≥ 0 x, y ∈ Z y ≤ 4 y ≥ 5 x ≥ 4 x ≤ 3 y ≤ 3 y ≥ 4 x ≥ 3 x ≤ 2 y ≤ 2 y ≥ 3 29 / 62

  6. Example min − x − y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 x, y ≥ 0 x, y ∈ Z y ≤ 4 y ≥ 5 x ≥ 4 x ≤ 3 y ≤ 3 y ≥ 4 x ≥ 3 x ≤ 2 y ≤ 2 y ≥ 3 29 / 62

  7. Example Min obj: - x - y Subject To c1: -2 x + 2 y >= 1 c2: -8 x + 10 y <= 13 Bounds x <= 2 y <= 2 End ==================================================================== CPLEX> optimize Dual simplex - Optimal: Objective = - 3.5000000000e+00 Solution time = 0.00 sec. Iterations = 0 (0) Deterministic time = 0.00 ticks (2.71 ticks/sec) CPLEX> display solution variables x Variable Name Solution Value x 1.500000 CPLEX> display solution variables y Variable Name Solution Value y 2.000000 30 / 62

  8. Example min − x − y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 x, y ≥ 0 x, y ∈ Z y ≤ 4 y ≥ 5 x ≥ 4 x ≤ 3 y ≤ 3 y ≥ 4 x ≥ 3 x ≤ 2 y ≤ 2 y ≥ 3 x ≥ 2 x ≤ 1 31 / 62

  9. Example min − x − y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 x, y ≥ 0 x, y ∈ Z y ≤ 4 y ≥ 5 x ≥ 4 x ≤ 3 y ≤ 3 y ≥ 4 x ≥ 3 x ≤ 2 y ≤ 2 y ≥ 3 x ≥ 2 x ≤ 1 31 / 62

  10. Example Min obj: - x - y Subject To c1: -2 x + 2 y >= 1 c2: -8 x + 10 y <= 13 Bounds x = 2 y <= 2 End ==================================================================== CPLEX> optimize Bound infeasibility column ’y’. Presolve time = 0.00 sec. (0.00 ticks) Presolve - Infeasible. Solution time = 0.00 sec. Deterministic time = 0.00 ticks (1.11 ticks/sec) 32 / 62

  11. Example min − x − y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 x, y ≥ 0 x, y ∈ Z y ≤ 4 y ≥ 5 x ≥ 4 x ≤ 3 y ≤ 3 y ≥ 4 x ≥ 3 x ≤ 2 y ≤ 2 y ≥ 3 x ≥ 2 x ≤ 1 33 / 62

  12. Example min − x − y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 x, y ≥ 0 x, y ∈ Z y ≤ 4 y ≥ 5 x ≥ 4 x ≤ 3 y ≤ 3 y ≥ 4 x ≥ 3 x ≤ 2 y ≤ 2 y ≥ 3 x ≥ 2 x ≤ 1 33 / 62

  13. Example Min obj: - x - y Subject To c1: -2 x + 2 y >= 1 c2: -8 x + 10 y <= 13 Bounds x <= 1 y <= 2 End ==================================================================== CPLEX> optimize Dual simplex - Optimal: Objective = - 3.0000000000e+00 Solution time = 0.00 sec. Iterations = 0 (0) Deterministic time = 0.00 ticks (2.40 ticks/sec) CPLEX> display solution variables x Variable Name Solution Value x 1.000000 CPLEX> display solution variables y Variable Name Solution Value y 2.000000 34 / 62

  14. Example min − x − y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 x, y ≥ 0 x, y ∈ Z y ≤ 4 y ≥ 5 x ≥ 4 x ≤ 3 y ≤ 3 y ≥ 4 x ≥ 3 x ≤ 2 y ≤ 2 y ≥ 3 x ≥ 2 x ≤ 1 35 / 62

  15. Pruning in Branch & Bound We have already seen that if relaxation is infeasible, ■ the problem can be pruned Now assume an (integral) solution has been previously found ■ If solution has cost Z then any pending problem P j whose relaxation has ■ optimal value ≥ Z can be ignored, since cost ( P j ) ≥ cost (LP( P j )) ≥ Z The optimum will not be in any descendant of P j ! This cost-based pruning of the search tree has a huge impact ■ on the efficiency of Branch & Bound 36 / 62

  16. Branch & Bound: Algorithm S := { P 0 } /* set of pending problems */ Z := + ∞ /* best cost found so far */ while S � = ∅ do remove P from S solve LP( P ) if LP( P ) is feasible then /* if unfeasible P can be pruned */ let β be optimal basic solution of LP( P ) if β satisfies integrality constraints then if cost ( β ) < Z then store β ; update Z else if cost(LP( P )) ≥ Z then continue /* P can be pruned */ let x j be integer variable such that β j �∈ Z ∪ { P ∧ x j ≤ ⌊ β j ⌋ , P ∧ x j ≥ ⌈ β j ⌉ } S := S return Z 37 / 62

  17. Heuristics in Branch & Bound Possible choices in Branch & Bound ■ Choice of the pending problem ◆ Depth-first search ■ Breadth-first search ■ Best-first search: assuming a relaxation is solved when it is added ■ to the set of pending problems, select the one with best cost value 38 / 62

  18. Heuristics in Branch & Bound Possible choices in Branch & Bound ■ Choice of the pending problem ◆ Depth-first search ■ Breadth-first search ■ Best-first search: assuming a relaxation is solved when it is added ■ to the set of pending problems, select the one with best cost value Choice of the branching variable: one that is ◆ closest to halfway two integer values ■ most important in the model (e.g., 0-1 variable) ■ biggest in a variable ordering ■ the one with the largest/smallest cost coefficient ■ 38 / 62

  19. Heuristics in Branch & Bound Possible choices in Branch & Bound ■ Choice of the pending problem ◆ Depth-first search ■ Breadth-first search ■ Best-first search: assuming a relaxation is solved when it is added ■ to the set of pending problems, select the one with best cost value Choice of the branching variable: one that is ◆ closest to halfway two integer values ■ most important in the model (e.g., 0-1 variable) ■ biggest in a variable ordering ■ the one with the largest/smallest cost coefficient ■ No known strategy is best for all problems! ■ 38 / 62

  20. Remarks on Branch & Bound If integer variables are not bounded, Branch & Bound may not terminate: ■ min 0 1 ≤ 3 x − 3 y ≤ 2 x, y ∈ Z is infeasible but Branch & Bound loops forever looking for solutions! 39 / 62

  21. Remarks on Branch & Bound If integer variables are not bounded, Branch & Bound may not terminate: ■ min 0 1 ≤ 3 x − 3 y ≤ 2 x, y ∈ Z is infeasible but Branch & Bound loops forever looking for solutions! E.g., we first find a solution with x = 2 3 . ■ 39 / 62

  22. Remarks on Branch & Bound If integer variables are not bounded, Branch & Bound may not terminate: ■ min 0 1 ≤ 3 x − 3 y ≤ 2 x, y ∈ Z is infeasible but Branch & Bound loops forever looking for solutions! E.g., we first find a solution with x = 2 3 . ■ In the subproblem with x ≥ 1 we get a solution with y = 1 3 . ■ 39 / 62

  23. Remarks on Branch & Bound If integer variables are not bounded, Branch & Bound may not terminate: ■ min 0 1 ≤ 3 x − 3 y ≤ 2 x, y ∈ Z is infeasible but Branch & Bound loops forever looking for solutions! E.g., we first find a solution with x = 2 3 . ■ In the subproblem with x ≥ 1 we get a solution with y = 1 3 . ■ In the subproblem with x ≥ 1 , y ≥ 1 we get a solution with x = 5 3 . ■ 39 / 62

  24. Remarks on Branch & Bound If integer variables are not bounded, Branch & Bound may not terminate: ■ min 0 1 ≤ 3 x − 3 y ≤ 2 x, y ∈ Z is infeasible but Branch & Bound loops forever looking for solutions! E.g., we first find a solution with x = 2 3 . ■ In the subproblem with x ≥ 1 we get a solution with y = 1 3 . ■ In the subproblem with x ≥ 1 , y ≥ 1 we get a solution with x = 5 3 . ■ In the subproblem with x ≥ 2 , y ≥ 1 we get a solution with y = 4 3 . ■ 39 / 62

  25. Remarks on Branch & Bound If integer variables are not bounded, Branch & Bound may not terminate: ■ min 0 1 ≤ 3 x − 3 y ≤ 2 x, y ∈ Z is infeasible but Branch & Bound loops forever looking for solutions! E.g., we first find a solution with x = 2 3 . ■ In the subproblem with x ≥ 1 we get a solution with y = 1 3 . ■ In the subproblem with x ≥ 1 , y ≥ 1 we get a solution with x = 5 3 . ■ In the subproblem with x ≥ 2 , y ≥ 1 we get a solution with y = 4 3 . ■ In the subproblem with x ≥ 2 , y ≥ 2 we get a solution with x = 8 3 . ■ 39 / 62

  26. Remarks on Branch & Bound If integer variables are not bounded, Branch & Bound may not terminate: ■ min 0 1 ≤ 3 x − 3 y ≤ 2 x, y ∈ Z is infeasible but Branch & Bound loops forever looking for solutions! E.g., we first find a solution with x = 2 3 . ■ In the subproblem with x ≥ 1 we get a solution with y = 1 3 . ■ In the subproblem with x ≥ 1 , y ≥ 1 we get a solution with x = 5 3 . ■ In the subproblem with x ≥ 2 , y ≥ 1 we get a solution with y = 4 3 . ■ In the subproblem with x ≥ 2 , y ≥ 2 we get a solution with x = 8 3 . ■ ... ■ 39 / 62

  27. Remarks on Branch & Bound After solving the relaxation of P , ■ we have to solve the relaxations of P ∧ x j ≤ ⌊ β j ⌋ and P ∧ x j ≥ ⌈ β j ⌉ These problems are similar. Do we have to start from scratch? ■ Can be reuse somehow the computation for P ? Idea: start from the optimal solution of the parent problem ■ 40 / 62

  28. Remarks on Branch & Bound Let us assume that P is of the form ■ min c T x Ax = b x ≥ 0 , x i ∈ Z ∀ i ∈ I Let B be an optimal basis of the relaxation ■ Let x j be integer variable which at optimal solution is assigned β j �∈ Z ■ Note that x j must be basic ■ Let us consider the problem P 1 = P ∧ x j ≤ ⌊ β j ⌋ ■ We add a fresh slack variable s and a new equation: P ∧ x j + s = ⌊ β j ⌋ ■ Since s is fresh we have ( x B , s ) defines a basis for the relaxation of P 1 ■ 41 / 62

  29. Remarks on Branch & Bound min − x − y min − x − y − 2 x + 2 y ≥ 1 − 2 x + 2 y − s 1 = 1 − 8 x + 10 y ≤ 13 ⇒ − 8 x + 10 y + s 2 = 13 x, y ≥ 0 x, y ≥ 0 x, y ∈ Z x, y ∈ Z Optimal basis of the linear relaxation is B = ( x, y ) with tableau ■ min − 17 2 + 9  2 s 1 + s 2   x = 4 − 5 2 s 1 − 1 2 s 2  y = 9 2 − 2 s 1 − 1 2 s 2  For the subproblem with y ≤ 4 we add equation y + s = 4 ■ B = ( x, y, s ) is a basis for this subproblem with tableau min − 17 2 + 9 2 s 1 + s 2    x = 4 − 5 2 s 1 − 1 2 s 2   y = 9 2 − 2 s 1 − 1 2 s 2    s = 4 − y = − 1 2 + 2 s 1 + 1  2 s 2 42 / 62

  30. Remarks on Branch & Bound ( x B , s ) defines a basis for the relaxation of P 1 ■ This basis is not feasible: ■ the value in the basic solution assigned to s is ⌊ β j ⌋ − β j < 0 . We would need a Phase I to apply the primal simplex method! But since s is a slack the reduced costs have not changed: ■ ( x B , s ) satisfies the optimality conditions! Dual simplex method can be used: ■ basis ( x B , s ) is already dual feasible, no need of (dual) Phase I In practice often the dual simplex only needs very few iterations ■ to obtain the optimal solution to the new problem 43 / 62

  31. Cutting Planes Let us consider a MIP of the form ■  �  Ax = b min c T x �   �  x ∈ R n where S = x ≥ 0 � x ∈ S � x i ∈ Z ∀ i ∈ I  � and its linear relaxation  min c T x � � Ax = b   x ∈ R n � where P = � x ∈ P x ≥ 0 � Let β be such that β ∈ P but β �∈ S . ■ a T x ≤ ˆ A cut for β is a linear inequality ˆ b such that a T σ ≤ ˆ ˆ b for any σ ∈ S (feasible solutions of the MIP respect the cut) ◆ a T β > ˆ and ˆ b ( β does not respect the cut) ◆ 44 / 62

  32. Cutting Planes max x + y max x + y y − 2 x + 2 y ≥ 1 − 8 x + 10 y ≤ 13 ( 4 , 4 . 5 ) x, y ≥ 0 x, y ∈ Z − 8 x + 10 y ≤ 13 ( 1 , 2 ) (0 , 1) − 2 x + 2 y ≥ 1 x + y ≤ 6 is a cut x + y ≤ 6 x ≥ 0 y ≥ 0 x 45 / 62

  33. Using Cuts for Solving MIP’s a T x ≤ ˆ Let ˆ b be a cut. Then the MIP ■ �  Ax = b  �  min c T x a T x ≤ ˆ �  ˆ b   where S ′ =  x ∈ R n � � x ∈ S ′ x ≥ 0 �  �  x i ∈ Z ∀ i ∈ I  � has the same set of feasible solutions S but its LP relaxation is strictly more constrained Instead of splitting into subproblems (Branch & Bound), ■ one can add the cut and solve the relaxation of the new problem In practice cuts are used together with Branch & Bound: ■ If after adding some cuts no integer solution is found, then branch This technique is called Branch & Cut 46 / 62

  34. Gomory Cuts There are several techniques for deriving cuts ■ Some are problem-specific (e.g., for the travelling salesman problem) ■ Here we will see a generic technique: Gomory cuts ■ Let us consider a basis B and let β be the associated basic solution. ■ Note that for all j ∈ R we have β j = 0 Let x i be a basic variable such that i ∈ I and β i �∈ Z ■ E.g., this happens in the optimal basis of the relaxation ■ when the basic solution does not meet the integrality constraints Let the row of the tableau corresponding to x i be of the form ■ x i = β i + � j ∈R α ij x j 47 / 62

  35. Gomory Cuts Let x ∈ S . Then x i ∈ Z and ■ x i = β i + � j ∈R α ij x j x i − β i = � j ∈R α ij x j Let δ = β i − ⌊ β i ⌋ . Then 0 < δ < 1 ■ Hence ■ x i − ⌊ β i ⌋ = x i − β i + β i − ⌊ β i ⌋ x i − β i + δ = δ + x i − β i = δ + � = j ∈R α ij x j 48 / 62

  36. Gomory Cuts x i − ⌊ β i ⌋ = δ + � j ∈R α ij x j δ = β i − ⌊ β i ⌋ Let us define ■ R + = { j ∈ R | α ij ≥ 0 } R − = { j ∈ R | α ij < 0 } Assume � j ∈R α ij x j ≥ 0 . ■ 49 / 62

  37. Gomory Cuts x i − ⌊ β i ⌋ = δ + � j ∈R α ij x j δ = β i − ⌊ β i ⌋ Let us define ■ R + = { j ∈ R | α ij ≥ 0 } R − = { j ∈ R | α ij < 0 } Assume � j ∈R α ij x j ≥ 0 . ■ Then δ + � j ∈R α ij x j > 0 and x i − ⌊ β i ⌋ ∈ Z imply � δ + α ij x j ≥ 1 j ∈R � � α ij x j ≥ α ij x j ≥ 1 − δ j ∈R + j ∈R α ij � 1 − δ x j ≥ 1 j ∈R + 49 / 62

  38. Gomory Cuts x i − ⌊ β i ⌋ = δ + � j ∈R α ij x j δ = β i − ⌊ β i ⌋ Let us define ■ R + = { j ∈ R | α ij ≥ 0 } R − = { j ∈ R | α ij < 0 } Assume � j ∈R α ij x j ≥ 0 . ■ Then δ + � j ∈R α ij x j > 0 and x i − ⌊ β i ⌋ ∈ Z imply � δ + α ij x j ≥ 1 j ∈R � � α ij x j ≥ α ij x j ≥ 1 − δ j ∈R + j ∈R α ij � 1 − δ x j ≥ 1 j ∈R + � − α ij � Moreover � x j ≥ 0 j ∈R − δ 49 / 62

  39. Gomory Cuts x i − ⌊ β i ⌋ = δ + � j ∈R α ij x j δ = β i − ⌊ β i ⌋ Let us define ■ R + = { j ∈ R | α ij ≥ 0 } R − = { j ∈ R | α ij < 0 } Assume � j ∈R α ij x j < 0 . ■ 50 / 62

  40. Gomory Cuts x i − ⌊ β i ⌋ = δ + � j ∈R α ij x j δ = β i − ⌊ β i ⌋ Let us define ■ R + = { j ∈ R | α ij ≥ 0 } R − = { j ∈ R | α ij < 0 } Assume � j ∈R α ij x j < 0 . ■ Then δ + � j ∈R α ij x j < 1 and x i − ⌊ β i ⌋ ∈ Z imply � δ + α ij x j ≤ 0 j ∈R � � α ij x j ≤ α ij x j ≤ − δ j ∈R j ∈R − � − α ij � � x j ≥ 1 δ j ∈R − 50 / 62

  41. Gomory Cuts x i − ⌊ β i ⌋ = δ + � j ∈R α ij x j δ = β i − ⌊ β i ⌋ Let us define ■ R + = { j ∈ R | α ij ≥ 0 } R − = { j ∈ R | α ij < 0 } Assume � j ∈R α ij x j < 0 . ■ Then δ + � j ∈R α ij x j < 1 and x i − ⌊ β i ⌋ ∈ Z imply � δ + α ij x j ≤ 0 j ∈R � � α ij x j ≤ α ij x j ≤ − δ j ∈R j ∈R − � − α ij � � x j ≥ 1 δ j ∈R − α ij Moreover � 1 − δ x j ≥ 0 j ∈R + 50 / 62

  42. Gomory Cuts In any case ■ � − α ij α ij � � � x j + 1 − δ x j ≥ 1 δ j ∈R + j ∈R − for any x ∈ S . However, when x = β this inequality is not satisfied (set x j = 0 for j ∈ R ) In the example: ■  min − 17 2 + 9 2 s 1 + s 2   x = 4 − 5 2 s 1 − 1 2 s 2  y = 9 2 − 2 s 1 − 1 2 s 2  y violates the integrality condition, we have δ = 1 j ∈R α ij x j = − 2 s 1 − 1 2 , � 2 s 2 The cut is 4 s 1 + s 2 ≥ 1 , which projected on x, y is y ≤ 4 . 51 / 62

  43. Ensuring All Vertices Are Integer Let us assume A, b have coefficients in Z ■ Sometimes it is possible to ensure for an IP that ■ all vertices of the relaxation are integer For instance, when the matrix A is totally unimodular: ■ the determinant of every square submatrix is 0 or ± 1 52 / 62

  44. Ensuring All Vertices Are Integer Let us assume A, b have coefficients in Z ■ Sometimes it is possible to ensure for an IP that ■ all vertices of the relaxation are integer For instance, when the matrix A is totally unimodular: ■ the determinant of every square submatrix is 0 or ± 1 In that case all bases have inverses with integer coefficients Recall Cramer’s rule: if B is an invertible matrix, then 1 B − 1 = det( B )adj( B ) where adj( B ) is the adjugate matrix of B Recall also that adj( B ) = (( − 1) i + j det( M ji )) 1 ≤ i,j ≤ n , where M ij is matrix B after removing the i -th row and the j -th column 52 / 62

  45. Ensuring All Vertices Are Integer Sufficient condition for total unimodularity of a matrix A : ■ (Hoffman & Gale’s Theorem) Each element of A is 0 or ± 1 1. 2. No more than two non-zeros appear in each columm 3. Rows can be partitioned in two subsets R 1 and R 2 s.t. (a) If a column contains two non-zeros of the same sign, the row of one of them belongs to one subset, and the row of the other, to the other subset (b) If a column contains two non-zeros of different signs, the rows of both of them belong to the same subset 53 / 62

  46. Assignment Problem n = # of workers = # of tasks ■ Each worker must be assigned to exactly one task ■ Each task is to be performed by exactly one worker ■ c ij = cost when worker i performs task j ■ 54 / 62

  47. Assignment Problem n = # of workers = # of tasks ■ Each worker must be assigned to exactly one task ■ Each task is to be performed by exactly one worker ■ c ij = cost when worker i performs task j ■ � 1 if worker i performs task j x ij = 0 otherwise min � n � n j =1 c ij x ij i =1 � n j =1 x ij = 1 ∀ i ∈ { 1 , . . . , n } � n ∀ j ∈ { 1 , . . . , n } i =1 x ij = 1 x ij ∈ { 0 , 1 } ∀ i, j ∈ { 1 , . . . , n } This problem satisfies Hoffman & Gale’s conditions ■ 54 / 62

  48. Ensuring All Vertices Are Integer Several kinds of IP’s satisfy Hoffman & Gale’s conditions: ■ Assignment ◆ Transportation ◆ Maximum flow ◆ Shortest path ◆ ... ◆ Usually ad-hoc network algorithms are more efficient for these problems ■ than the simplex method as presented here 55 / 62

  49. Ensuring All Vertices Are Integer Several kinds of IP’s satisfy Hoffman & Gale’s conditions: ■ Assignment ◆ Transportation ◆ Maximum flow ◆ Shortest path ◆ ... ◆ Usually ad-hoc network algorithms are more efficient for these problems ■ than the simplex method as presented here But: ■ The simplex method can be specialized: network simplex method ◆ Simplex techniques can be applied ◆ if the problem is not a purely network one but has extra constraints 55 / 62

  50. Expressing Logical Constraints Sometimes we want to have an indicator variable of a contraint: ■ a 0 / 1 variable equal to 1 iff the constraint is true (= reification in CP) E.g., let us to encode δ = 1 ↔ a T x ≤ b , where δ is a 0 / 1 var ■ 56 / 62

  51. Expressing Logical Constraints Sometimes we want to have an indicator variable of a contraint: ■ a 0 / 1 variable equal to 1 iff the constraint is true (= reification in CP) E.g., let us to encode δ = 1 ↔ a T x ≤ b , where δ is a 0 / 1 var ■ Assume a T x ∈ Z for all feasible solution x ■ Let U be an upper bound of a T x − b for all feasible solutions Let L be a lower bound of a T x − b for all feasible solutions 56 / 62

  52. Expressing Logical Constraints Sometimes we want to have an indicator variable of a contraint: ■ a 0 / 1 variable equal to 1 iff the constraint is true (= reification in CP) E.g., let us to encode δ = 1 ↔ a T x ≤ b , where δ is a 0 / 1 var ■ Assume a T x ∈ Z for all feasible solution x ■ Let U be an upper bound of a T x − b for all feasible solutions Let L be a lower bound of a T x − b for all feasible solutions δ = 1 → a T x ≤ b 1. can be encoded with a T x − b ≤ U (1 − δ ) 56 / 62

  53. Expressing Logical Constraints Sometimes we want to have an indicator variable of a contraint: ■ a 0 / 1 variable equal to 1 iff the constraint is true (= reification in CP) E.g., let us to encode δ = 1 ↔ a T x ≤ b , where δ is a 0 / 1 var ■ Assume a T x ∈ Z for all feasible solution x ■ Let U be an upper bound of a T x − b for all feasible solutions Let L be a lower bound of a T x − b for all feasible solutions δ = 1 → a T x ≤ b 1. can be encoded with a T x − b ≤ U (1 − δ ) δ = 1 ← a T x ≤ b 2. δ = 0 → a T x > b δ = 0 → a T x ≥ b + 1 can be encoded with a T x − b ≥ ( L − 1) δ + 1 56 / 62

  54. Expressing Logical Constraints We want to encode δ = 1 ↔ a T x ≤ b , where δ is a 0 / 1 var ■ Now assume that a T x is real-valued. ■ Let U be an upper bound of a T x − b for all feasible solutions Let L be a lower bound of a T x − b for all feasible solutions δ = 1 → a T x ≤ b 1. can be encoded with a T x − b ≤ U (1 − δ ) 57 / 62

  55. Expressing Logical Constraints We want to encode δ = 1 ↔ a T x ≤ b , where δ is a 0 / 1 var ■ Now assume that a T x is real-valued. ■ Let U be an upper bound of a T x − b for all feasible solutions Let L be a lower bound of a T x − b for all feasible solutions δ = 1 → a T x ≤ b 1. can be encoded with a T x − b ≤ U (1 − δ ) δ = 1 ← a T x ≤ b 2. δ = 0 → a T x > b Can only be modeled if we allow for a tolerance ǫ 57 / 62

  56. Expressing Logical Constraints We want to encode δ = 1 ↔ a T x ≤ b , where δ is a 0 / 1 var ■ Now assume that a T x is real-valued. ■ Let U be an upper bound of a T x − b for all feasible solutions Let L be a lower bound of a T x − b for all feasible solutions δ = 1 → a T x ≤ b 1. can be encoded with a T x − b ≤ U (1 − δ ) δ = 1 ← a T x ≤ b 2. δ = 0 → a T x > b Can only be modeled if we allow for a tolerance ǫ δ = 0 → a T x ≥ b + ǫ can be encoded with a T x − b ≥ ( L − ǫ ) δ + ǫ 57 / 62

  57. Expressing Logical Constraints We want to encode δ = 1 ↔ a T x = b , where δ is a 0 / 1 var ■ Assume that a T x is real-valued. ■ Let U be upper bound of a T x − b for all feasible solutions Let L be lower bound of a T x − b for all feasible solutions 58 / 62

  58. Expressing Logical Constraints We want to encode δ = 1 ↔ a T x = b , where δ is a 0 / 1 var ■ Assume that a T x is real-valued. ■ Let U be upper bound of a T x − b for all feasible solutions Let L be lower bound of a T x − b for all feasible solutions δ = 1 → a T x ≤ b a T x − b ≤ U (1 − δ ) 1. ⇒ 58 / 62

  59. Expressing Logical Constraints We want to encode δ = 1 ↔ a T x = b , where δ is a 0 / 1 var ■ Assume that a T x is real-valued. ■ Let U be upper bound of a T x − b for all feasible solutions Let L be lower bound of a T x − b for all feasible solutions δ = 1 → a T x ≤ b a T x − b ≤ U (1 − δ ) 1. ⇒ δ = 1 → a T x ≥ b a T x − b ≥ L (1 − δ ) 2. ⇒ 58 / 62

  60. Expressing Logical Constraints We want to encode δ = 1 ↔ a T x = b , where δ is a 0 / 1 var ■ Assume that a T x is real-valued. ■ Let U be upper bound of a T x − b for all feasible solutions Let L be lower bound of a T x − b for all feasible solutions δ = 1 → a T x ≤ b a T x − b ≤ U (1 − δ ) 1. ⇒ δ = 1 → a T x ≥ b a T x − b ≥ L (1 − δ ) 2. ⇒ δ = 1 ← a T x = b 3. δ = 0 → a T x � = b δ = 0 → a T x < b ∨ a T x > b 58 / 62

  61. Expressing Logical Constraints We want to encode δ = 1 ↔ a T x = b , where δ is a 0 / 1 var ■ Assume that a T x is real-valued. ■ Let U be upper bound of a T x − b for all feasible solutions Let L be lower bound of a T x − b for all feasible solutions δ = 1 → a T x ≤ b a T x − b ≤ U (1 − δ ) 1. ⇒ δ = 1 → a T x ≥ b a T x − b ≥ L (1 − δ ) 2. ⇒ δ = 1 ← a T x = b 3. δ = 0 → a T x � = b δ = 0 → a T x < b ∨ a T x > b Let ǫ be the tolerance, δ ′ , δ ′′ auxiliary 0 / 1 vars δ = 0 → δ ′ = 0 ∨ δ ′′ = 0 δ ′ + δ ′′ − δ ≤ 1 ⇒ δ ′ = 0 → a T x ≤ b − ǫ a T x − b ≤ ( U + ǫ ) δ ′ − ǫ ⇒ δ ′′ = 0 → a T x ≥ b + ǫ a T x − b ≥ ( L − ǫ ) δ ′′ + ǫ ⇒ 58 / 62

  62. Expressing Logical Constraints Boolean expressions can be modeled with 0 / 1 vars ■ If x i is a 0 / 1 variable, ■ let X i be a boolean variable such that X i is true iff x i = 1 X 1 ∨ X 2 x 1 + x 2 ≥ 1 iff X 1 ∧ X 2 iff x 1 = x 2 = 1 ¬ X 1 iff x 1 = 0 X 1 → X 2 iff x 1 ≤ x 2 X 1 ↔ X 2 iff x 1 = x 2 59 / 62

  63. Example Let X i represent “Ingredient i is in the blend”, i ∈ { A, B, C } . Express the sentence “If ingredient A is in the blend, then ingredient B or C (or both) must also be in the blend” with linear constraints. 60 / 62

  64. Example Let X i represent “Ingredient i is in the blend”, i ∈ { A, B, C } . Express the sentence “If ingredient A is in the blend, then ingredient B or C (or both) must also be in the blend” with linear constraints. We need to express X A → ( X B ∨ X C ) . ■ Equivalently, ¬ X A ∨ X B ∨ X C . ■ ¬ X A ∨ X B ∨ X C is equivalent to (1 − x A ) + x B + x C ≥ 1 . ■ So x B + x C ≥ x A ■ 60 / 62

  65. Example (Fixed Setup Charge) Let x be the quantity of a product with unit production cost c 1 . If the product is manufactured at all, there is a setup cost c 0 � 0 if x = 0 Cost of producing x units = c 0 + c 1 x if x > 0 Want to minimize costs. Model as a MIP? (for simplicity, additional constraints are not specified and can be omitted) 61 / 62

  66. Example (Fixed Setup Charge) Let x be the quantity of a product with unit production cost c 1 . If the product is manufactured at all, there is a setup cost c 0 � 0 if x = 0 Cost of producing x units = c 0 + c 1 x if x > 0 Want to minimize costs. Model as a MIP? (for simplicity, additional constraints are not specified and can be omitted) Let δ be 0 / 1 var such that x > 0 → δ = 1 (i.e., δ = 0 → x ≤ 0 ): add constraint x − Uδ ≤ 0 , where U is the upper bound on x Then the cost is c 0 δ + c 1 x . No need to express x > 0 ← δ = 1 , i.e. x = 0 → δ = 0 Minimization will make δ = 0 if possible (i.e., if x = 0 ) 61 / 62

Recommend


More recommend