Abstract: The simplex algorithm is a classic algorithm for solving linear programming problems (LP). The most time-consuming module in the simplex algorithm is the algorithm for calculating the inverse matrix of the matrix. The network simplex algorithm is a special version of the simplex algorithm, which uses spanning tree bases to more effectively solve linear programming problems with pure network forms.
This article is shared from the HUAWEI cloud community " Network Simplex Algorithm ", the original author: Yun Xiaofan.
Preface
The simplex algorithm is a classic algorithm for solving linear programming problems (LP). The most time-consuming module in the simplex algorithm is the algorithm for calculating the inverse matrix of the matrix. The network simplex algorithm is a special version of the simplex algorithm, which uses spanning tree bases to more effectively solve linear programming problems with pure network forms. Such LP problem can be modeled by the formula on the directed graph as a minimum cost flow problem.
Network simplex refers to the LP problem of the following form:
Among them, each column contains only one 1 and one -1, and the other coefficients are all 0. Below is an example:
This problem can be seen as a graphical form of minimum cost flow problems. Graph G=(V,E), vertex V represents a row (constraint), edge E represents a column (variable), for a column in matrix A, there is a 1 in the i-th row, and a -1 in the k-th row, which represents a graph G An edge in (i, k).
For the above example, it can be represented by the following figure:
The network flow problem satisfies Hoffman&Gale's conditions, so an integer solution can be guaranteed.
Incidence matrix:
For the graph G=(V,E), the incidence matrix A can be expressed as:
The incidence matrix in the above example can be expressed as:
path:
Connected graph: Any two vertices in the graph have paths.
Spanning tree: a subgraph T of graph G, including all vertices in graph G.
Property: rank(A)=n-1, n is the number of nodes.
We add a variable w, add a column in A
, Any value in r∈{1,2……n}, w=0, then the LP model is:
Among them, r is called root vertex, w is called root edge (going nowhere)
For the above example, if you choose the root node r=2
A is the incidence matrix of graph G, and T is the spanning tree of G, then the basis of (A│e_r) B=e_r∪{a_e |e∈T}
Simplex algorithm:
We can traverse first from the root node, get y2=0, y1-y2=1, y1-y3=10, that is, traverse base 5, base 1, and base 4 in turn
Pseudo code: (recursive)
solve(Vertex p,Tree S){//p is the root node of tree S
Vertex v=root(S);
if(v==r) y[r]=c[w];
else if ((p,v)∈E y[v]=y[p]-c[(p,v)];
else y[v]=y[p]+c[(v,p)];
solve(v,S.left());
solve(v,S.right());
}
Reference: https://www.cs.upc.edu/~erodri/webpage/cps/theory/lp/network/slides.pdf
Click to follow and learn about Huawei Cloud's fresh technology for the first time~
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。