计算几何 W40 Linear Programming
阅读材料
课堂笔记
Convex Hull and Sorting
convex hull algorithms: .
can we do better?
convex hull of points is equivalent to sorted numbers.
worst-case is optimal.
fewer than n points on the hull
?
Marriage Before Conquest
MbC(P:l,r): find Upper Hull of P from x-coordinates l to r
- find median x-coordinate . partition into . times
- find the bridge, uv, over .
- remove the points below the bridge.
- recurse: &
if step 2 can be done in linear time, the total time is .
How to find bridges
finding a bridge is equivalent to finding a line that:
- passes above all the points
- has the lowest intersection point with the separating line (the lowest point that is not inside the convex hull)
find and s.t.:
- for every input point
- is minimized
Linear Programming
unknowns:
minimize:
s.t.
, , are given as input.
dimensions
There a and b are unknown.
can be solved in time on average.
1D Linear Programming
unknown
minimize s.t. for i in 1 to n
find feasible region
possible cases: feasible, infeasible or unbounded.
running time
2D Linear Programming
unknown
minimize s.t. for i in 1 to n
假设一些直线找到了一个可行区域
现在就只需要平移 这条直线,以找到最小值。
- initialize .
- for i=1 to n
- if constraint i does not violate v: do nothing
- else solve 1D Linear programming with constraints 1 to i-1 on boundary of constraint i
step 2.2 might run n times time in total.
A randomized incremental algorithm
- initialize v
- randomly relabel (shuffle) constraints
- for i = 1 to n
if constraint i does not violate v: do nothing
else solve 1D Linear Programming with constraints 1 to i-1 on boundary of constraint i
意思就是新增的这个约束 i 对应的直线,把 x2 解出来,代入到前面 1 到 i-1 中的 x2,可以得到一个一维的线性规划问题。
improves from to time on average.
backward analysis (a claim): the probability that step 3.2 runs during the i-th iteration of the for loop is
expected running time:
how to shuffle?
Place i in a random non-empty spot for i = 1 to n
fill i-th spot randomly for i = 1 to n
fill i-th spot randomly from i = n to 1
To proof the claim:
consider the step 3.2
every constraint is a line, we have n of them. .
we have n positions in our shuffle.
the line is placed randomly in these n positions.
then the probability of entering 3.2:
- Probability entering 3.2 at is: , because only two lines determin final result. since the order of lines are shuffled, the probability of n-th line is one of the two determin line is .
- consider feasible region, the optimal solution is adjacent to 2 constraints . for i-th line probability would be
Chan’s Algortihm
陈氏算法,计算凸包的一种快速算法,时间复杂度
预设一个凸包上的点的个数 . 从 开始尝试。
对每一个 i:
将当前所有点分成 份,分别用 graham scan 计算凸包,这一步的时间复杂度为 。计算 次,所以总的时间复杂度为 。
从这些凸包上 x 坐标最小的点开始,找到这 个凸包合并的上凸包。就是对当前的点,找到通过分别二分查找 这 个子凸包上和当前点连线正切值最小的点。这一步是 .
因为假设凸包点数的上界是 h,最多要找 h 次,所以找到这些子凸包的公共上凸包的总时间为
如果假设正确,那么整个算法的时间复杂度为 。
如果算法错误,i++,并继续尝试计算。
假设最终凸包上的点数为 ,那么最多测试 次。
所以总的时间复杂度为
妙啊!