Differential constraint system learning notes, constraint system learning notes
Each constraint in a differential constraint system is a simple inequality shown in the following figure:
Xj-xi <= bk.
For example, to solve an inequality group
X1-x5 ≤-1x2-x5 ≤ 1x3-x1 ≤ 5x4-x1 ≤ 4x4-x3 ≤-1x5-x3 ≤-3x5-x4 ≤-3 one solution to this problem is x = (-5,-3,0,-1,-4 ), another solution, y = (, 4, 1), is related: Each element in y is 5 larger than the corresponding element in x.
Theorem: set x = (x1, x2 ,..., Xn) is a solution of the differential constrained system Ax ≤ B. d is any constant. Then x + d = (x1 + d, x2 + d ,..., Xn + d) is also a solution for the system Ax ≤ B.
Constraint graph: for a given difference constraint system AX <= B, the corresponding constraint graph is a directed graph G = (V, E) with weight)
Here
V = {v0, v1. .. vn}
E = {(vi, vj): xj-xi <= bk is a constraint}U {(V0, v1)... (v0, vn )}
The node v0 is added by ourselves to ensure that at least one node exists in the graph, from which we can start to reach all other nodes.
The weight of edge set (v0, vi) is 0, and the weight of (vi, vj) is bk. Then we can get a constraint diagram describing the differential constraint system.
Now we can find a solution for the differential constraint system by finding the shortest path in the corresponding constraint graph.
Theorem: 1. For a given difference constraint system, if the corresponding constraint graph does not contain a loop with a negative weight
X = {d [1], d [2]... d [n]} is a feasible solution of the system. d [I] indicates the shortest path from v0 to vi.
2. If G contains a loop with a negative weight, the system has no feasible solution.
Proof: First prove the first conclusion,
That is, when the constraint graph does not contain a loop with a negative weight, for any side (vi, vj), because
D [j] <= d [I] + w (I, j), that is, d [j]-d [I] <= w (I, j ), therefore, the conclusion is true.
The second conclusion is now proved.
If G contains a negative ring, there is no feasible solution. Set the loop with a negative weight to (v1, v2... vk). Here v1 = vk.
Loop c corresponds to the following differential inequality groups:
X2-x1 <= w (v1, v2)
X3-x2 <= w (v2, v3)
....
Xk-XK-1 <= w (vk-1, vk)
Add the two sides of the equation, 0 on the left, and the sum of the weights of the ring on the right. Therefore, when the ring is a negative ring, the inequality is not true, so there is no solution at this time.
Solve the difference constraint system.
You can use the Bellman-Ford algorithm to solve the difference constraint system.
Because the constraint chart contains the edges from the source node v0 to all other nodes, any loop with a negative weight can be reached from the node v0. If the Bellman_Ford algorithm returns true, the shortest path weight gives a feasible solution of the system. If false is returned, the differential constraint system does not.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.