simplex
DESCRIPTION
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. - PowerPoint PPT PresentationTRANSCRIPT
Simplex
“walk on the verticesof the feasible region”
v = current vertexif neighbor v’ of v with better objectivethen move to v’
Simplex
“walk on the verticesof the feasible region”
vertex = feasible point defined by a collection of d inequalities
neighbors = vertices sharing d-1 of the inequalities
Simplex v = current vertexif neighbor v’ of v with better objectivethen move to v’max cT x
Ax bx 0
assume v = (0,...,0)T
i such that ci > 0 iff v is not optimal
Simplex v = current vertexif neighbor v’ of v with better objectivethen move to v’max cT x
Ax bx 0
v’ = (0,..,xi,..,0)T
Make xi as big as possible stopper: aj x = bj
Simplex v = current vertexif neighbor v’ of v with better objectivethen move to v’max cT x
Ax bx 0
v’ = (0,..,xi,..,0)T
Make xi as big as possible stopper: aj x = bj
xi’ = bj – aj xSubstitute:
Simplex
max 2x+yx+y 4y-x 1x-y 2y 2x 0y 0
Is (x,y)=(0,0) optimal?
Simplex
max 2x+yx+y 4y-x 1x-y 2y 2x 0y 0
Let’s increase y as much as we can.
Simplex
max 2x+yx+y 4y-x 1x-y 2y 2x 0y 0
substitute z=1-(y-x)
Simplex
max 2x+yx+y 4y-x 1x-y 2y 2x 0y 0
substitute z=1-(y-x)z 0y x-z+1
Simplex
max 2x+yx+y 4y-x 1x-y 2y 2x 0y 0
y x-z+1
max 3x-z+12x-z 3z 0z 1x-z 1x 0z-x 1
Simplex
max 3x-z+12x-z 3z 0z 1x-z 1x 0z-x 1
Is (x,z)=(0,0) optimal?
Simplex
max 3x-z+12x-z 3z 0z 1x-z 1x 0z-x 1
Let’s increase x as much as we can.
Simplex
max 3x-z+12x-z 3z 0z 1x-z 1x 0z-x 1
substitute w=1-(x-z)
Simplex
max 3x-z+12x-z 3z 0z 1x-z 1x 0z-x 1
substitute w=1-(x-z)w 0x 1+z-w
Simplex
max 3x-z+12x-z 3z 0z 1x-z 1x 0z-x 1
x 1+z-w
max 2z-3w+4z-2w 1z 0z 1w 0w-z 1w 2
Simplex
max 2z-3w+4z-2w 1z 0z 1w 0w-z 1w 2
Is (z,w)=(0,0) optimal?
Simplex
max 2z-3w+4z-2w 1z 0z 1w 0w-z 1w 2
Let’s increase z as much as we can.
Simplex
max 2z-3w+4z-2w 1z 0z 1w 0w-z 1w 2
substitute u=1-(z-2w)
Simplex
max 2z-3w+4z-2w 1z 0z 1w 0w-z 1w 2
substitute u=1-(z-2w)u 0z 1+2w-u
Simplex
max 2z-3w+4z-2w 1z 0z 1w 0w-z 1w 2
z 1+2w-u
max w-2u+6u 0u-2w 12w-u 2w 0u-w 2w 2
Simplex
max w-2u+6u 0u-2w 12w-u 2w 0u-w 2w 2
Is (u,w)=(0,0) optimal?
Simplex
max w-2u+6u 0u-2w 12w-u 2w 0u-w 2w 2
Let’s increase w as much as we can.
Simplex
max w-2u+6u 0u-2w 12w-u 2w 0u-w 2w 2
substitute v=2-(2w-u)
Simplex
max w-2u+6u 0u-2w 12w-u 2w 0u-w 2w 2
substitute v=2-(2w-u)v 0w 1+u/2-v/2
Simplex
max w-2u+6u 0u-2w 12w-u 2w 0u-w 2w 2
w1+u/2-v/2
max 7-3u/2-v/2u 0v 3v 0v-u 2u+v 6u-v 2
Simplex
max 7-3u/2-v/2u 0v 3v 0v-u 2u+v 6u-v 2
Is (u,v)=(0,0) optimal?
Simplex
max 7-3u/2-v/2u 0v 3v 0v-u 2u+v 6u-v 2
Is (u,v)=(0,0) optimal? YES
7
Simplex
(u,v)=(0,0)
w 1+u/2-v/2 = 1z 1+2w-u = 3x 1+z-w = 3
y x-z+1 = 1
(x,y)=(3,1)
Simplex
(x,y)=(3,1)max 2x+yx+y 4y-x 1x-y 2y 2x 0y 0
is an optimal solution
Simplex – geometric view
(x,y)=(3,1)max 2x+yx+y 4y-x 1x-y 2y 2x 0y 0
Getting the first point
min cT x Ax=bx 0
min 1T zA x + z = bx 0z 0
wlog b 0
Points, lines
point = (x,y)
line = (x1,y1),(x2,y2)
2 points
=
Line as a point and a vector
point = (x,y)
line = (x1,y1),(x2-x1,y2-y1)
point and a vector=
x1+t (x2-x1),y1+t (y2-y1)
Is point on a line?
point = (x,y)
line = (x1,y1),(x2,y2)
x=x1+t (x2-x1)y=y1+t (y2-y1)
Is point on a line?
point = (x,y)
line = (x1,y1),(x2,y2)
t (x2-x1)=x-x_1t (y2-y1)=y-y_1
x2-x1 x-x1
y2-y1 y-y1( )det
Is point on a line?
point = (x,y)
line = (x1,y1),(x2,y2)
x2-x1 x-x1
y2-y1 y-y1( )det
is on
if and only if
= 0
Is point on a line?
x2-x1 x-x1
y2-y1 y-y1( )det
=0 for x on the line>0
<0
Line segment
line segment = (x1,y1),(x2,y2)
x=x1+t (x2-x1)y=y1+t (y2-y1)
t [0,1]
Do two line segments intersect?
a1=(x1,y1), a2=(x2,y2) a3=(x3,y3), a4= (x4,y4)
a1
a2
a3
a4
L1
L2
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
Many segments, do any 2 intersect?
(a1,b1)(a2,b2) ...(an,bn)
O(n2) 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 “neighborson the sweep line”
Sweep algorithm
sort the endpoints by x-coord p1,...,p2n
T empty B-treefor 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
Area of a simple polygon
(x1,y1)
(x3,y3)
(x2,y2)
Area of a simple polygon
(x1,y1),...,(xn,yn)
Area of a simple polygon
(x1,y1),...,(xn,yn)
R=0for i from 1 to n do R=R+(yi+1+yi)*(xi+1-xi)return |R|/2
(xn+1,yn+1)=(x1,y1)
Convex hull smallest convex setcontaining all the points
Convex hull smallest convex setcontaining all the points
Jarvis march
find the left-most point
(assume no 3 points colinear)
s
Jarvis march
find the point that appears most to the right looking from s
(assume no 3 points colinear)
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-coordp srepeat 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 quntil p = s