• No results found

Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method

N/A
N/A
Protected

Academic year: 2021

Share "Lecture 3. Linear Programming. 3B1B Optimization Michaelmas 2015 A. Zisserman. Extreme solutions. Simplex method. Interior point method"

Copied!
41
0
0

Loading.... (view fulltext now)

Full text

(1)

Lecture 3

3B1B Optimization Michaelmas 2015 A. Zisserman

Linear Programming

• Extreme solutions

• Simplex method

• Interior point method

• Integer programming and relaxation

(2)

The Optimization Tree

(3)

A linear function to be maximized

maximize f(x) =

c

1

x

1

+ c

2

x

2

+ … + c

n

x

n

Problem constraints

subject to

a

11

x

1

+ a

12

x

2

+ … + a

1n

x

n <

b

1

a

21

x

1

+ a

22

x

2

+ … + a

2n

x

n <

b

2

a

m1

x

1

+ a

m2

x

2

+ … + a

mn

x

n <

b

m

Non-negative variables

e.g. x

1

, x

2 >

0

Linear Programming

The name is historical, it should really be called Linear Optimization.

The problem consists of three parts:

(4)

Linear Programming

The problem is usually expressed in matrix form and then it becomes:

Maximize c > x

subject to Ax b , x ≥ 0

where A is a m × n matrix.

The objective function, c > x , and constraints, Ax b , are all linear functions of x .

(Linear programming problems are convex, so a local optimum is the

global optimum.)

(5)

Suppose that a farmer has a piece of farm land, say A square

kilometers large, to be planted with either wheat or barley or some combination of the two.

The farmer has a limited permissible amount F of fertilizer and P of insecticide which can be used, each of which is required in different amounts per unit area for wheat (F

1

, P

1

) and barley (F

2

, P

2

).

Let S

1

be the selling price of wheat, and S

2

the price of barley, and denote the area planted with wheat and barley as x

1

and x

2

respectively.

The optimal number of square kilometers to plant with wheat vs. barley can be expressed as a linear programming problem.

Example 1

x

1

x

2

A

(6)

Example 1 cont.

Maximize S

1

x

1

+ S

2

x

2

(the revenue – this is the “objective function”) subject to x

1

+x

2

< A (limit on total area)

F

1

x

1

+ F

2

x

2

< F (limit on fertilizer)

P

1

x

2

+ P

2

x

2

< P (limit on insecticide)

x

1

>= 0, x

2

> 0 (cannot plant a negative area)

which in matrix form becomes maximize

subject to

(7)

Example 2: Max flow

Given: a weighted directed graph, source s, destination t

Interpret edge weights as capacities Goal: Find maximum flow from s to t

• Flow does not exceed capacity in any edge

• Flow at every vertex satisfies equilibrium [ flow in equals flow out ]

e.g. oil flowing through pipes, internet routing

(8)

Example 3 cont.

Slide: Robert Sedgewick and Kevin Wayne

(9)

Example 2 cont.

(10)

Example 3: shortest path

Given: a weighted directed graph, with a single source s

Distance from s to v: length of the shortest part from s to v

Goal: Find distance (and shortest path) to every vertex

e.g. plotting routes on Google maps

(11)

Application

Minimize number of stops

(lengths = 1)

Minimize amount of time

(positive lengths)

(12)

LP – why is it important?

We have seen examples of:

• allocating limited resources

• network flow

• shortest path Others include:

• matching

• assignment …

It is a widely applicable problem-solving model because:

• non-negativity is the usual constraint on any variable that represents an amount of something

• one is often interested in bounds imposed by limited resources.

Dominates world of industry

(13)

Linear Programming – 2D example

x 1 + x 2 ≤ 2 x 1 ≤ 1.5 x 1 + 8

3 x 2 ≤ 4 x 1 , x 2 ≥ 0

Inequality constraints:

Cost function:

x max 1 ,x 2 f (x 1 , x 2 )

f (x 1 , x 2 ) = 0x 1 + 0.5x 2

(14)

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0

0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

x1 + x2 = 2

x1 = 1.5

x1 + 8

3x2 = 4

x 1 + x 2 ≤ 2 x 1 ≤ 1.5 x 1 + 8

3 x 2 ≤ 4 x 1 , x 2 ≥ 0

Inequality constraints:

Feasible Region

x 1

x 2

(15)

x 1 + x 2 ≤ 2 x 1 ≤ 1.5 x 1 + 8

3 x 2 ≤ 4 x 1 , x 2 ≥ 0

Inequality constraints:

LP example

z

x 1

x 2

z = 0.5x 2 Cost function:

max x

1

,x

2

f (x 1 , x 2 )

f (x 1 , x 2 ) = 0x 1 + 0.5x 2

feasible region

extreme point

(16)

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0

0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

LP example

x 1

x 2

x 1 + x 2 ≤ 2 x 1 ≤ 1.5 x 1 + 8

3 x 2 ≤ 4 x 1 , x 2 ≥ 0

Inequality constraints:

Cost function:

max x

1

,x

2

f (x 1 , x 2 )

f (x 1 , x 2 ) = 0x 1 + 0.5x 2

feasible region

contour lines

extreme point

(17)

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0

0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

LP example – change of cost function

x 1

x 2

x 1 + x 2 ≤ 2 x 1 ≤ 1.5 x 1 + 8

3 x 2 ≤ 4 x 1 , x 2 ≥ 0

Inequality constraints:

Cost function:

max x

1

,x

2

f (x 1 , x 2 )

f (x 1 , x 2 ) = c > x

= c 1 x 1 + c 2 x 2

feasible region

contour lines extreme point

c

(18)

Linear Programming – optima at vertices

• The key point is that for any (linear) objective function the optima only occur at the corners (vertices) of the feasible polygonal region (never on the interior region).

• Similarly, in 3D the optima only occur at the vertices of a polyhedron (and in nD at the vertices of a polytope).

• However, the optimum is not necessarily unique: it is possible to have a

set of optimal solutions covering an edge or face of a polyhedron.

(19)

-5 0 5 10 15 -5

0 5 10 15

Cf Constrained Quadratic Optimization

z

x 1

x 2

feasible region

extreme point

(20)

Linear Programming – solution idea

So, even though LP is formulated in terms of continuous variables, x, there are only a finite number of discrete possible solutions that need be explored.

How to find the maximum??

• Try every vertex? But there are too many in large problems.

• Instead, simply go from one vertex to the next increasing the cost function each time, and in an intelligent manner to avoid having to visit (and test) every vertex.

• This is the idea of the simplex algorithm

(21)

Sketch solutions for optimization methods

1. Simplex method

• Tableau exploration of vertices based on linear algebra

2. Interior point method

• Continuous optimization with constraints cast as barriers

We will look at 2 methods of solution:

(22)

1. Simplex method

• Optimum must be at the intersection of constraints

• Intersections are easy to find, change inequalities to equalities

• Intersections are called basic solutions

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

x1 + x2 = 2

x1 = 1.5

x1 + 8

3x2 = 4

a

b

c

e d

f

• some intersections are outside the feasible region (e.g. f) and so need not be considered

• the others (which are vertices

of the feasible region) are called

basic feasible solutions

(23)

Worst complexity …

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

x1 + x2 = 2

x1 = 1.5

x1 + 8

3x2 = 4

a

b

c

e d

f There are

C

nm

= m!

(m − n)! n!

possible solutions, where m is the total number of con- straints and n the dimension of the space.

In this case

C

25

= 5!

(3)! 2! = 10

However, for large problems

the number of solutions can

be huge, and it is not realis-

tic to explore them all.

(24)

The Simplex Algorithm

• Start from a basic feasible solution (i.e. a vertex of feasible region)

• Consider all the vertices connected to the current one by an edge

• Choose the vertex which increases the cost function the most (and is still feasible of course)

• Repeat until no further increases are possible

In practice this is very efficient and avoids visiting all vertices

(25)

Matlab LP Function linprog

Linprog() for medium scale problems uses the Simplex algorithm Example

Find x that minimizes f(x) = –5x

1

– 4x

2

–6x

3

, subject to

x

1

– x

2

+ x

3

≤ 20

3x

1

+ 2x

2

+ 4x

3

≤ 42 3x

1

+ 2x

2

≤ 30

0 ≤ x

1

, 0 ≤ x

2

, 0 ≤ x

3

.

>> f = [-5; -4; -6];

>> A = [1 -1 1 3 2 4 3 2 0];

>> b = [20; 42; 30];

>> lb = zeros(3,1);

>> x = linprog(f,A,b,[],[],lb);

>> Optimization terminated.

>> x x =

0.0000 15.0000

3.0000

(26)

MOSEK

For large scale linear and quadratic optimization problems

(27)

2. Interior Point Method

• Solve LP using continuous optimization methods

• Represent inequalities by barrier functions

• Follow path through interior of feasible region to vertex

c

(28)

We wish to solve the following problem Minimize f ( x ) = c

>

x

subject to a

i>

x ≤ b

i

, i = 1 . . . m

Problem could be rewritten as Minimize f ( x ) +

Xm i=1

I( a

i>

x − b

i

)

where I is the indicator function

I(u) = 0 for u ≤ 0

= ∞ for u > 0

The difficulty here is that I(u) is not differentiable.

Barrier function method

(29)

Approximate indicator function by logarithmic barrier Minimize f ( x ) 1

t

Xm i=1

log( − a

i>

x + b

i

)

• for t > 0 , −(1/t) log(−u) is a smooth approximation of I(u)

• approximation improves as t → ∞

Approximation via logarithmic barrier functon

− log(−u)

t

(30)

Function f (x) to be minimized subject to x ≥ −1, x ≤ 1

Minimizing function for different Values of t.

Minima converge to the constrained minimum.

Function tf (x) − log(1 − x

2

) for increasing values of t.

(31)

Problem becomes

Minimize tf ( x ) −

Xm i=1

log( − a

i>

x + b

i

) Algorithm

• Solve using Newton’s method

• t → μt

• repeat until convergence

As t increases this converges to the solution of the original problem

Algorithm for Interior Point Method

(32)

Diagram copied from Boyd and Vandenberghe

Example

(33)

Integer programming

There are often situations where the solution is required to be an integer or have boolean values (0 or 1 only).

For example:

• assignment problems

• scheduling problems

• matching problems

Linear programming can also be used for these cases

(34)

Example: assignment problem

agents

tasks

1 2 3 4 5

1 2 3 4 5

Assignment constraints:

• each agent assigned to one task only

• each task assigned to one agent only Objective:

• assign n agents to n tasks to minimize total cost

(35)

Example: assignment problem

agents

tasks

1 2 3 4 5

1 2 3 4 5

Assignment constraints:

• each agent assigned to one task only

• each task assigned to one agent only Objective:

• assign n agents to n tasks to minimize total cost

(36)

cost matrix

a g e n t s

tasks tasks

a

g

e

n

t

s

(37)

Example: assignment problem

Problem specification

x

ij

is the assignment of agent i to task j (can take values 0 or 1) c

ij

is the (non-negative) cost of assigning agent i to task j

Minimize total cost f ( x ) =

Pij

x

ij

c

ij

over the n

2

variables x

ij

0 1 0 0 0

0 0 0 1 0

0 0 1 0 0

0 0 0 0 1

1 0 0 0 0

each agent i assigned to one task only

• only one entry in each row

each task j assigned to one agent only

• only one entry in each column Example solution for x

ij

tasks j a

g

e

n

t

s

i

(38)

Example: assignment problem

min

xij

f ( x ) =

X

ij

x

ij

c

ij

subject to

(inequalities)

X

j

x

ij

≤ 1, ∀i each agent assigned to at most one task (equalities)

X

i

x

ij

= 1, ∀j each task assigned to exactly one agent This is a relaxation of the problem because the variables x

ij

are not forced to take boolean values.

However, it can be shown that the solution x

ij

only takes the values 0 or 1

Linear Programme formulation

0 1 0 0 0

0 0 0 1 0

0 0 1 0 0

0 0 0 0 1

1 0 0 0 0

tasks j a

g e n t s

i

(39)

-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 -2

-1.5 -1 -0.5 0 0.5 1 1.5

Agents to tasks assignment problem

agents tasks

-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5

-2 -1.5 -1 -0.5 0 0.5 1 1.5

Optimal agents to tasks assignment cost: 11.735499

agents tasks

Cost of assignment = distance between agent and task

e.g. application: tracking, correspondence

(40)

Example application: tracking pedestrians

Multiple Object Tracking using Flow Linear Programming, Berclaz, Fleuret & Fua, 2009

(41)

What is next?

• Convexity (when does a function have only a global minimum?)

• Robust cost functions

• Stochastic algorithms

References

Related documents

was the negative influence of July maximum temperature on current year growth, which has been 259. significant

I Simplex and interior point methods produce optimal primal and dual solutions.. I Interior point methods typically maintain feasible primal and dual solutions in

Strategy's Expected Result/Impact: Increased student achievement Staff Responsible for Monitoring: Principal, LPAC Administrator Title I Schoolwide Elements: 2.4, 2.6.

This is able to support the definition of targeting and incentive systems for the sales force that are extremely effective in terms of achieving the budgeted results: in

The objective of the project is to analysis material flow for injection molding process in order to get the suitable runner and gate system and design the two-plate injection mold

History, classification, basic components, CPU, memory, peripheral devices, storage media and devices, physical and logical storage, data organization, file storage, programs

These include the use of Gittins Index in place of the estimated click through rates in the objective function, the use of an interior point method for linear programming as a

This article is based on findings from and reflections on a research programme aimed at studying the impacts of conversions of commercial farms to wildlife-based production –