directory
1. Introduction to MIP (Mixed Integer Program)
Case2: Knapsack Problem(Branch and Bound)
Case3: Coloring Problem(Big-M Transformation)
Case4: Node Packing(Clique Facets)
6. Facility location programming assignments
1. Introduction to MIP (Mixed Integer Program)
The MIP problem is to add the constraint of variable rounding to the LP problem
Case1: Warehouse Location
In the warehouse location problem, the warehouse has a series of options. Given a customer, it is required to decide where to build a warehouse and assign each customer to the corresponding warehouse. Each warehouse has a fixed cost, from the warehouse to each customer. There are transportation costs, and the total cost is required to be minimum
- Decision variable: two 0/1 decision variables, representing whether to open warehouse w, representing whether warehouse w serves customer c
- Constraints: A warehouse can serve customers only when it is opened , and a customer can only be served by one warehouse
- Objective function: warehouse establishment cost + transportation cost
In the above model, the decision variable is a 0/1 variable. This problem is also called a 0/1 integer programming problem. The MIP model usually sets the decision variable as a 0/1 variable
Case2: Knapsack Problem(Branch and Bound)
There are many ways to solve the MIP problem, branch and bound is a commonly used method
- Bounding: Finding Optimistic Slack
- Branching: Divide the problem into multiple sub-problems
Linear relaxation : The optimal solution of the LP model obtained without considering the integer constraints on the variables in the MIP problem is called the linear relaxation of MIP
Any MIP problem can be regarded as LP relaxation + additional constraints (some variables require integers) , so LP relaxation is a MIP reduction constraint, or a more relaxed version, the feasible region of any MIP must be included in its LP relaxation feasible In the domain, if it is a maximization problem, the optimal solution of LP relaxation >= the optimal solution of MIP. Similarly, if it is a minimization problem, the optimal solution of LP relaxation <= the optimal solution of MIP. LP relaxation can be combined with the Branch and bound method to find the upper bound (lower bound)
- The current linear relaxation is worse than the previously found solution. Stop exploring this subproblem. For example, the relaxed solution when x2=1 is 71.33, which is worse than the 80 that has been found. Stop searching this branch.
- The current linear relaxation is an integer solution, and a feasible solution has been found, such as x1=1, x2=0, x3=1
- Otherwise, select the non-integer value variable in the linear relaxation solution to branch, and create two sub-problems, such as the initial linear relaxation is 92, where x1=1, x2=0.25, x3=1, select x2 to branch into x2=0 and x2 = 1 two sub-questions
The meaning of LP relaxation of MIP is to give the upper bound (lower bound) of the optimal solution, a good MIP model will have a good LP relaxation
2. MIP model (modeling)
The model of MIP problem can be expressed in various forms, so what is a good MIP model?
- Prefer to use 0/1 variables
- have good linear relaxation
For example, in Case1: Warehouse Location, for constraint 1: it can also be expressed in other ways, as shown in the figure below, the original constraint is for each warehouse and each customer, a total of WC constraints, now for each warehouse, use a constraint The condition replaces the original C constraints, and the two constraints are compared: the solution of the original constraint must be included in the solution of the later constraint. Therefore, the original constraint is more effective. The problem is to minimize the total cost. The LP relaxation target value of the original constraint is larger, and its linear relaxation is better, and the lower bound found is higher. Different MIP models have different slack constraints and different search efficiencies, which is the importance of the model
Case3: Coloring Problem(Big-M Transformation)
In the graph coloring problem, there is a constraint: adjacent points are of different colors, expressed mathematically , this is not a linear constraint, so conversion is required, which means that there are two situations: x is larger or y is larger, which is not the case in MIP problems Connection constraints are allowed, so the big M method is introduced. The variable b is a 0/1 variable, and M is an infinite number . As shown below, it becomes two constraints, which are satisfied when b=0 and satisfied when b=1 . After converting with big M, the MIP model is established, and the LP relaxation is solved. The target value is 0, indicating that we need at least one color. Obviously, this relaxation is invalid, and the MIP model needs to be rebuilt.
In the above model, the decision variable is the color of each point, and the value range is {0,1,2,3}. As mentioned earlier, MIP prefers 0/1 variables, so modify the decision variables and replace them with 0/1 variables , set 4 0/1 variables for each point, representing whether the point uses a certain color
- Each point can only have one color:
- Adjacent points of different colors:
The LP relaxation solved by the MIP model using 0/1 variables is 0.27. Note that the value of v here starts from 0, which means that v can be at least 1, and a total of at least 2 colors are required, which is better than the previous model LP relaxation. , after obtaining the relaxation, it is necessary to select the variable branch, the number of variable branches is too much, so this model can also be improved
Combining the first constraint and the second constraint into the following constraints, LP relaxation has fewer nodes to search
Different MIP models have different LP relaxations, which will affect the next search efficiency, so it is necessary to choose a good MIP model
3. Cutting planes
The core idea of the cutting plane is that the LP relaxation optimal solution can be improved by adding constraints without eliminating any feasible solution of MIP. As shown in the figure below, the difference between LP relaxation and MIP is that the solution of the latter requires integers, so the part of LP relaxation that does not contain any integer solutions can be completely removed, which can ensure that the feasible solution of MIP is not destroyed while increasing LP Relax the bounding capacity of the optimal solution.
Constraints that meet the above requirements are called Gomory Cuts. The key to the cut plane method is to find Gomory cuts, add new constraints, and update the LP relaxation solution. Select the variable with fractional value from the LP relaxation solution, as shown in the figure below, assuming that x1 takes the value of b1 as a fractional value, a cut can be obtained through the following conversion: , so as to obtain a new constraint. Resolve the LP relaxation adding the new constraints.
Take the following question as an example
- The table after the original LP relaxation solution is as follows, x2=3/2, so select the line x2 to cut and find the new constraint
- Replace the above constraints with the above x1, x2, it can be obtained , indicating that the original feasible region has been cut, introduce the artificial variable s1, update the iteration table, the value of x1 is 2/3, select the row of x1 to get cut, the new constraint is
- Replace the above constraints with x1, x2, you can get x1-x2>=0, and cut a part of the non-integer feasible region
In summary, the idea of cutting plane method
- Solve a Linear Relaxation Problem
- Select a variable whose value is a fraction and add Gomory cut
- Obtaining a New Optimal Solution Using the Dual Simplex Method
- Iterate until the solution satisfies the integer requirement or there are no more feasible solutions
On the basis of Gomory cutting, Balas, Ceria, Cornuejols, Natraj (1994-1996) studied how to combine Gomory cutting with branch and bound to generate multiple cuts at one time, and generate cuts as long as it is useful to improve the boundary of the objective function value. Currently In the MIP problem, the SOTA model edge uses Gomory cutting.
4. Polyhedral Cuts
The cutting method described above is just one of them. A problem can use multiple cutting types according to the problem structure. This section introduces Polyhedral cuts
- Convex Hull: In a real vector space V, for a given set X, the intersection S of all convex sets containing X is called the convex hull of X
- Polyhedral cuts: cuts representing the convex hull of the integer solution
Polyhedral cuts are not like the cuts obtained from the iterative table introduced in Section 3, but start from the structural properties of the constraints themselves. They are also effective and will not eliminate any feasible solutions of MIP, but will make the current LP relaxation The basic feasible solution is not feasible, so as to improve the ability of LP to relax the boundary. Polyhedral cuts are illustrated with the following two examples
Case4: Node Packing(Clique Facets)
The node packing problem is also called Maximal Independent Set, that is, the maximum independent set problem. The maximum independent set is a subset of graph vertices, satisfying that there is no edge connection between any two points. It is represented by MIP as shown in the right figure. The decision variable is a 0/1 variable, which means that every Whether the vertices are in the maximum independent set, the linear relaxation solution is 1/2 for all variables, and there are too many score variables, so it needs to be improved, find the cut
- Clique: A complete subgraph of an undirected graph. If some vertices of an undirected graph are adjacent to each other, it is said that these vertices form a clique
- Maximal clique: the complete graph with the most points in an undirected graph
The largest independent set requires no connection between vertices, indicating that a vertex in a largest clique can only have at most one vertex in an independent set. Therefore, the above node packing problem can use 5 largest clique constraints as cuts to solve the linear relaxation x1=0, than the original is better
Case3: Coloring Problem
Also in the graph coloring problem, the method of clique cutting can be used to improve the linear relaxation
5. Branch and Cut
5.1 Cover Cuts
- Cover: For constraints , the set is a cover if
Since x is a 0/1 variable, it means that the variables in the coverage C cannot all take 1, and the coverage inequality can be obtained . If the variables in the coverage C cannot all take 1, then adding a variable with a larger coefficient than the variable covering C becomes E (C), which also satisfies this constraint, becomes a strengthened coverage inequality, as shown in the right figure below. According to the original constraint, the coverage inequality x3+x4+x5+x6<=3, the coefficient ratios of x1 and x2 are x3, x4, x5, x5 The coefficients are all large, so the enhanced coverage inequality can be obtained as x1+x2+x3+x4+x5+x6<=3
5.2 Branch and Cut
- Model the problem as a MIP model
- Solve the linear relaxation, if integer, end
- Find a cut that cuts the linear slack, if such a cut can be found, go back to step 2
- Branch on variable if found without cutting
The key step of Branch and Cut: Finding a suitable cut can improve the linear relaxation optimal solution. We don't need to list all the cuts at once, we just need to find the cut that removes the current optimal solution
5.3 The Separation Problem
From the Branch and Cut process, it can be seen that the optimal solution of linear relaxation can be improved through some cutting. We hope to know whether there are Cover Cuts that can be cut to make the original optimal solution an infeasible solution. Make cutting more efficient. In order to remove , it is necessary to find the violated constraint, which violates the previous coverage inequality, and the coverage inequality can be rewritten as A minimization problem, as shown in the right figure below, if and the objective function value is less than 1, then a cut that can be removed is found , and the variables of form a cut
5.4 MIP+TSP
The MIP modeling idea of TSP is as follows:
- Decision variable: represents whether the edge e is in the solution
- Constraints: There are two edges connected to each vertex
The problem of subcircle will appear when solving TSP with conventional thinking, and the following ideas can be used to eliminate the problem of subcircle
(1)Separation of Subtour Constraints
(2)Comb Constraints
According to the TSP base test, subtour elimination can achieve an optimality gap of 2%, and subtour + comb cuts can achieve an optimality gap of 0.5%. Cutting + linear relaxation is a very effective way to solve MIP, and there are many types of cutting, specific problems and specific applications.
6. Facility location programming assignments
Gurobi solution, 80/80, see my github for the code, or refer to using Gurobi+python to solve the facility location problem (facility location)_bujbujbiu's blog-CSDN blog