Simplex walk on the vertices of the feasible
Simplex “walk on the vertices of the feasible region” v = current vertex if neighbor v’ of v with better objective then move to v’
Simplex “walk on the vertices of the feasible region” vertex = feasible point defined by a collection of d inequalities neighbors = vertices sharing d-1 of the inequalities
Simplex max c. T x Ax b x 0 v = current vertex if neighbor v’ of v with better objective then move to v’ assume v = (0, . . . , 0)T i such that ci > 0 iff v is not optimal
v = current vertex if neighbor v’ of v with better objective then move to v’ Simplex max c. T x Ax b x 0 v’ = T (0, . . , xi, . . , 0) Make xi as big as possible stopper: a j x = bj
v = current vertex if neighbor v’ of v with better objective then move to v’ Simplex max c. T x Ax b x 0 v’ = T (0, . . , xi, . . , 0) Make xi as big as possible stopper: a j x = bj Substitute: xi’ = bj – aj x
Simplex max 2 x+y 4 y-x 1 x-y 2 y 2 x 0 y 0 Is (x, y)=(0, 0) optimal?
Simplex max 2 x+y 4 y-x 1 x-y 2 y 2 x 0 y 0 Let’s increase y as much as we can.
Simplex max 2 x+y 4 y-x 1 x-y 2 y 2 x 0 y 0 substitute z=1 -(y-x)
Simplex max 2 x+y 4 y-x 1 x-y 2 y 2 x 0 y 0 substitute z=1 -(y-x) z 0 y x-z+1
Simplex max 2 x+y 4 y-x 1 x-y 2 y x 0 y 0 x-z+1 max 3 x-z+1 2 x-z 3 z 0 z 1 x-z 1 x 0 z-x 1
Simplex max 3 x-z+1 2 x-z 3 z 0 z 1 x-z 1 x 0 z-x 1 Is (x, z)=(0, 0) optimal?
Simplex max 3 x-z+1 2 x-z 3 z 0 z 1 x-z 1 x 0 z-x 1 Let’s increase x as much as we can.
Simplex max 3 x-z+1 2 x-z 3 z 0 z 1 x-z 1 x 0 z-x 1 substitute w=1 -(x-z)
Simplex max 3 x-z+1 2 x-z 3 z 0 z 1 x-z 1 x 0 z-x 1 substitute w=1 -(x-z) w 0 x 1+z-w
Simplex max 3 x-z+1 2 x-z 3 z 0 z 1 x-z 1 x 0 x z-x 1 1+z-w max 2 z-3 w+4 z-2 w 1 z 0 z 1 w 0 w-z 1 w 2
Simplex max 2 z-3 w+4 z-2 w 1 z 0 z 1 w 0 w-z 1 w 2 Is (z, w)=(0, 0) optimal?
Simplex max 2 z-3 w+4 z-2 w 1 z 0 z 1 w 0 w-z 1 w 2 Let’s increase z as much as we can.
Simplex max 2 z-3 w+4 z-2 w 1 z 0 z 1 w 0 w-z 1 w 2 substitute u=1 -(z-2 w)
Simplex max 2 z-3 w+4 z-2 w 1 z 0 z 1 w 0 w-z 1 w 2 substitute u=1 -(z-2 w) u 0 z 1+2 w-u
Simplex max 2 z-3 w+4 z-2 w 1 z 0 z 1 z w 0 w-z 1 w 2 1+2 w-u max w-2 u+6 u 0 u-2 w 1 2 w-u 2 w 0 u-w 2 w 2
Simplex max w-2 u+6 u 0 u-2 w 1 2 w-u 2 w 0 u-w 2 w 2 Is (u, w)=(0, 0) optimal?
Simplex max w-2 u+6 u 0 u-2 w 1 2 w-u 2 w 0 u-w 2 w 2 Let’s increase w as much as we can.
Simplex max w-2 u+6 u 0 u-2 w 1 2 w-u 2 w 0 u-w 2 w 2 substitute v=2 -(2 w-u)
Simplex max w-2 u+6 u 0 u-2 w 1 2 w-u 2 w 0 u-w 2 w 2 substitute v=2 -(2 w-u) v 0 w 1+u/2 -v/2
Simplex max w-2 u+6 u 0 u-2 w 1 2 w-u 2 w 1+u/2 -v/2 w 0 u-w 2 w 2 max 7 -3 u/2 -v/2 u 0 v 3 v 0 v-u 2 u+v 6 u-v 2
Simplex max 7 -3 u/2 -v/2 u 0 v 3 v 0 v-u 2 u+v 6 u-v 2 Is (u, v)=(0, 0) optimal?
Simplex max 7 -3 u/2 -v/2 u 0 v 3 v 0 v-u 2 u+v 6 u-v 2 7 Is (u, v)=(0, 0) optimal? YES
Simplex (u, v)=(0, 0) w 1+u/2 -v/2 = 1 z 1+2 w-u = 3 x 1+z-w = 3 y x-z+1 = 1 (x, y)=(3, 1)
Simplex max 2 x+y 4 y-x 1 x-y 2 y 2 x 0 y 0 (x, y)=(3, 1) is an optimal solution
Simplex – geometric view max 2 x+y 4 y-x 1 x-y 2 y 2 x 0 y 0 (x, y)=(3, 1)
Getting the first point T c min x Ax=b x 0 wlog b 0 min 1 T z Ax+z=b x 0 z 0
Points, lines point = (x, y) line = (x 1, y 1), (x 2, y 2) = 2 points
Line as a point and a vector point = (x, y) x 1+t (x 2 -x 1), y 1+t (y 2 -y 1) = line = (x 1, y 1), (x 2 -x 1, y 2 -y 1) point and a vector
Is point on a line? point = (x, y) x=x 1+t (x 2 -x 1) y=y 1+t (y 2 -y 1) line = (x 1, y 1), (x 2, y 2)
Is point on a line? point = (x, y) t (x 2 -x 1)=x-x_1 t (y 2 -y 1)=y-y_1 det ( x 2 -x 1 x-x 1 y 2 -y 1 y-y 1 line = (x 1, y 1), (x 2, y 2) )
Is point on a line? point = (x, y) is on line = (x 1, y 1), (x 2, y 2) if and only if det ( x 2 -x 1 x-x 1 y 2 -y 1 y-y 1 ) =0
Is point on a line? det ( x 2 -x 1 x-x 1 y 2 -y 1 y-y 1 ) =0 for x on the line >0 <0
Line segment x=x 1+t (x 2 -x 1) y=y 1+t (y 2 -y 1) t [0, 1] line segment = (x 1, y 1), (x 2, y 2)
Do two line segments intersect? a 1=(x 1, y 1), a 2=(x 2, y 2) a 3=(x 3, y 3), a 4= (x 4, y 4) a 3 L 1 a 2 a 1 and a 2 on different sides of L 2 a 3 and a 4 on different sides of L 1 or endpoint of a segment lies on the other segment L 2 a 4
Many segments, do any 2 intersect? (a 1, b 1) (a 2, b 2). . . (an, bn) 2 O(n ) algorithm
Many segments, do any 2 intersect? O(n log n) algorithm assume no two points have the same x-coordinate no 3 segments intersect at one point
Sweep algorithm
Sweep algorithm sort points by the x-coordinate
Sweep algorithm events: insert segment delete segment
Sweep algorithm will find the left-most intersection point the lines are “neighbors on the sweep line”
Sweep algorithm sort the endpoints by x-coord p 1, . . . , p 2 n T empty B-tree for i from 1 to 2 n do if pi is the left point of a segment s INSERT s into T check if s intersects prev(s) or next(s) in T if pi is the right point of a segment s check if prev(s) interesects next(s) in T DELETE s from T
Area of a simple polygon (x 3, y 3) (x 2, y 2) (x 1, y 1)
Area of a simple polygon (x 1, y 1), . . . , (xn, yn)
Area of a simple polygon (x 1, y 1), . . . , (xn, yn) (xn+1, yn+1)=(x 1, y 1) R=0 for i from 1 to n do R=R+(yi+1+yi)*(xi+1 -xi) return |R|/2
Convex hull smallest convex set containing all the points
Convex hull smallest convex set containing all the points
Jarvis march (assume no 3 points colinear) s find the left-most point
Jarvis march (assume no 3 points colinear) s find the point that appears most to the right looking from s
Jarvis march (assume no 3 points colinear) s p find the point that appears most to the right looking from p
Jarvis march (assume no 3 points colinear)
Jarvis march (assume no 3 points colinear)
Jarvis march (assume no 3 points colinear) s point with smallest x-coord p s repeat PRINT(p) q point other than p for i from 1 to n do if i p and point i to the right of line (p, q) then q i p q until p = s
- Slides: 58