Title: Simplex
1Simplex
walk on the vertices of the feasible region
v current vertex if ? neighbor v of v with
better objective then move to v
2Simplex
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
3Simplex
v current vertex if ? neighbor v of v with
better objective then move to v
max cT x Ax ? b x ? 0
assume v (0,...,0)T
? i such that ci gt 0 iff v is not optimal
4Simplex
v current vertex if ? neighbor v of v with
better objective then move to v
max cT x Ax ? b x ? 0
v (0,..,xi,..,0)T
Make xi as big as possible stopper
aj x bj
5Simplex
v current vertex if ? neighbor v of v with
better objective then move to v
max cT x Ax ? b x ? 0
v (0,..,xi,..,0)T
Make xi as big as possible stopper
aj x bj
xi bj aj x
Substitute
6Simplex
max 2xy xy ? 4 y-x ? 1 x-y ? 2 y ? 2 x ? 0 y ? 0
Is (x,y)(0,0) optimal?
7Simplex
max 2xy xy ? 4 y-x ? 1 x-y ? 2 y ? 2 x ? 0 y ? 0
Lets increase y as much as we can.
8Simplex
max 2xy xy ? 4 y-x ? 1 x-y ? 2 y ? 2 x ? 0 y ? 0
substitute z1-(y-x)
9Simplex
max 2xy xy ? 4 y-x ? 1 x-y ? 2 y ? 2 x ? 0 y ? 0
substitute z1-(y-x) z ? 0
y ? x-z1
10Simplex
max 2xy xy ? 4 y-x ? 1 x-y ? 2 y ? 2 x ? 0 y ? 0
max 3x-z1 2x-z ? 3 z ? 0 z ? 1 x-z ? 1 x ? 0 z-x
? 1
y ? x-z1
11Simplex
max 3x-z1 2x-z ? 3 z ? 0 z ? 1 x-z ? 1 x ? 0 z-x
? 1
Is (x,z)(0,0) optimal?
12Simplex
max 3x-z1 2x-z ? 3 z ? 0 z ? 1 x-z ? 1 x ? 0 z-x
? 1
Lets increase x as much as we can.
13Simplex
max 3x-z1 2x-z ? 3 z ? 0 z ? 1 x-z ? 1 x ? 0 z-x
? 1
substitute w1-(x-z)
14Simplex
max 3x-z1 2x-z ? 3 z ? 0 z ? 1 x-z ? 1 x ? 0 z-x
? 1
substitute w1-(x-z) w ? 0
x ? 1z-w
15Simplex
max 3x-z1 2x-z ? 3 z ? 0 z ? 1 x-z ? 1 x ? 0 z-x
? 1
max 2z-3w4 z-2w ? 1 z ? 0 z ? 1 w ? 0 w-z ? 1 w
? 2
x ? 1z-w
16Simplex
max 2z-3w4 z-2w ? 1 z ? 0 z ? 1 w ? 0 w-z ? 1 w
? 2
Is (z,w)(0,0) optimal?
17Simplex
max 2z-3w4 z-2w ? 1 z ? 0 z ? 1 w ? 0 w-z ? 1 w
? 2
Lets increase z as much as we can.
18Simplex
max 2z-3w4 z-2w ? 1 z ? 0 z ? 1 w ? 0 w-z ? 1 w
? 2
substitute u1-(z-2w)
19Simplex
max 2z-3w4 z-2w ? 1 z ? 0 z ? 1 w ? 0 w-z ? 1 w
? 2
substitute u1-(z-2w) u ? 0
z ? 12w-u
20Simplex
max 2z-3w4 z-2w ? 1 z ? 0 z ? 1 w ? 0 w-z ? 1 w
? 2
max w-2u6 u ? 0 u-2w ? 1 2w-u ? 2 w ? 0 u-w ?
2 w ? 2
z ? 12w-u
21Simplex
max w-2u6 u ? 0 u-2w ? 1 2w-u ? 2 w ? 0 u-w ?
2 w ? 2
Is (u,w)(0,0) optimal?
22Simplex
max w-2u6 u ? 0 u-2w ? 1 2w-u ? 2 w ? 0 u-w ?
2 w ? 2
Lets increase w as much as we can.
23Simplex
max w-2u6 u ? 0 u-2w ? 1 2w-u ? 2 w ? 0 u-w ?
2 w ? 2
substitute v2-(2w-u)
24Simplex
max w-2u6 u ? 0 u-2w ? 1 2w-u ? 2 w ? 0 u-w ?
2 w ? 2
substitute v2-(2w-u) v ? 0
w ? 1u/2-v/2
25Simplex
max w-2u6 u ? 0 u-2w ? 1 2w-u ? 2 w ? 0 u-w ?
2 w ? 2
max 7-3u/2-v/2 u ? 0 v ? 3 v ? 0 v-u ? 2 uv ?
6 u-v ? 2
w?1u/2-v/2
26Simplex
max 7-3u/2-v/2 u ? 0 v ? 3 v ? 0 v-u ? 2 uv ?
6 u-v ? 2
Is (u,v)(0,0) optimal?
27Simplex
max 7-3u/2-v/2 u ? 0 v ? 3 v ? 0 v-u ? 2 uv ?
6 u-v ? 2
7
YES
Is (u,v)(0,0) optimal?
28Simplex
(u,v)(0,0)
w ? 1u/2-v/2 1
z ? 12w-u 3
x ? 1z-w 3
y ? x-z1 1
(x,y)(3,1)
29Simplex
(x,y)(3,1)
max 2xy xy ? 4 y-x ? 1 x-y ? 2 y ? 2 x ? 0 y ? 0
is an optimal solution
30Simplex geometric view
(x,y)(3,1)
max 2xy xy ? 4 y-x ? 1 x-y ? 2 y ? 2 x ? 0 y ? 0
31Getting the first point
min 1T z A x z b x ? 0 z ? 0
min cT x Axb x ? 0
wlog b ? 0
32(No Transcript)
33Points, lines
point (x,y)
line (x1,y1),(x2,y2)
2 points
34Line as a point and a vector
point (x,y)
x1t (x2-x1),y1t (y2-y1)
line (x1,y1),(x2-x1,y2-y1)
point and a vector
35Is point on a line?
point (x,y)
xx1t (x2-x1) yy1t (y2-y1)
line (x1,y1),(x2,y2)
36Is point on a line?
point (x,y)
t (x2-x1)x-x_1 t (y2-y1)y-y_1
line (x1,y1),(x2,y2)
37Is point on a line?
point (x,y)
is on
line (x1,y1),(x2,y2)
if and only if
0
38Is point on a line?
0 for x on the line
gt0
lt0
39Line segment
xx1t (x2-x1) yy1t (y2-y1)
t ? 0,1
line segment (x1,y1),(x2,y2)
40Do two line segments intersect?
a1(x1,y1), a2(x2,y2) a3(x3,y3), a4 (x4,y4)
a3
L2
L1
a2
a4
a1
a1 and a2 on different sides of L2 a3 and a4 on
different sides of L1 or endpoint of a segment
lies on the other segment
41Many segments, do any 2 intersect?
(a1,b1) (a2,b2) ... (an,bn)
O(n2) algorithm
42Many 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
43Sweep algorithm
44Sweep algorithm
sort points by the x-coordinate
45Sweep algorithm
events insert segment delete segment
46Sweep algorithm
will find the left-most intersection point the
lines are neighbors on the sweep line
47Sweep algorithm
sort the endpoints by x-coord ? p1,...,p2n T?
empty B-tree for i from 1 to 2n 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
48Area of a simple polygon
(x3,y3)
(x2,y2)
(x1,y1)
49Area of a simple polygon
(x1,y1),...,(xn,yn)
50Area of a simple polygon
(x1,y1),...,(xn,yn)
(xn1,yn1)(x1,y1)
R0 for i from 1 to n do RR(yi1yi)(xi1-xi
) return R/2
51Convex hull
smallest convex set containing all the points
52Convex hull
smallest convex set containing all the points
53Jarvis march
(assume no 3 points colinear)
s
find the left-most point
54Jarvis march
(assume no 3 points colinear)
s
find the point that appears most to the right
looking from s
55Jarvis march
(assume no 3 points colinear)
s
find the point that appears most to the right
looking from p
p
56Jarvis march
(assume no 3 points colinear)
57Jarvis march
(assume no 3 points colinear)
58Jarvis 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