ENM 503 Lesson 7 – Discrete Models

41
ENM 503 Lesson 7 – Discrete Models Combinatorial Problems and their Solutions I am very discrete.

description

I am very discrete. ENM 503 Lesson 7 – Discrete Models. Combinatorial Problems and their Solutions. The Lineup. The General Problem The Transportation Problem The Assignment Problem The Knapsack Problem The Traveling Salesman Problem The Postman problem. The General IP Problem . - PowerPoint PPT Presentation

Transcript of ENM 503 Lesson 7 – Discrete Models

Page 1: ENM 503 Lesson 7 – Discrete Models

ENM 503Lesson 7 – Discrete Models

Combinatorial Problems and their Solutions

I am very discrete.

Page 2: ENM 503 Lesson 7 – Discrete Models

The Lineup

The General Problem The Transportation Problem The Assignment Problem The Knapsack Problem The Traveling Salesman Problem The Postman problem

Page 3: ENM 503 Lesson 7 – Discrete Models

The General IP Problem

1

1

max/ min

: 1,2,...,

0,1,2,3,...

n

j jj

n

ij j ij

j

z c x

subject to a x b for i m

x

Why this is just a linear program with integer restrictions on the variables.

Page 4: ENM 503 Lesson 7 – Discrete Models

Combinatorial Optimization Problems

Optimization problem having a finite number of discrete solutions.

One solution approach is to explicitly generate and evaluate all possible solutions Explicit enumeration

Consider an IP problem with 100 variables where xj = 0, 1, 2, …, 50; j = 1,2, …, 100 number of possible solutions = 51100

Explicit enumeration not possible Implicit enumeration – attempt to account for all

possible solution without enumerating all of them

Page 5: ENM 503 Lesson 7 – Discrete Models

An Integer Program

x1

x2

2

1

1 2

max z = x1 + 5x2

subj to: x1 + 10x2 20

x1 2x1, x2 are integers

. .

..

lattice points

Page 6: ENM 503 Lesson 7 – Discrete Models

Why not just round the LP solution?

x1

x2

2

1

1 2

. .

..

LP solutionx1 = 2, x2 = 9/5z* = 11

round (2,2)infeasible

Animated

max z = x1 + 5x2

subj to: x1 + 10x2 20

x1 2x1, x2 are integers

Page 7: ENM 503 Lesson 7 – Discrete Models

Rounding doesn’t always work!

x1

x2

2

1

1 2

. .

..

optimal IP solutionx1 = 0, x2 = 2z = 10

feasible rounded solutionx1 = 2, x2 = 1z = 7

Animated

max z = x1 + 5x2

subj to: x1 + 10x2 20

x1 2x1, x2 are integers

LP solutionx1 = 2, x2 = 9/5z* = 11

Page 8: ENM 503 Lesson 7 – Discrete Models

An IP Example

Max z = 4.8x1 + 6.1x2 + 4.5x3 + 5.2x4

subj. to:x1 + x2 + x3 + x4 200

2.3x1 + 4.5x2 + 6.8x3 + 2.5x4 15011.3x1 + 10.5x2 + 9.3x3 + 11.6x4 4003.4x1 + 5.3x2 + 2.1x3 + 1.8x4 125

x1, x2, x3, x4 = 0, 1, 2, …

Page 9: ENM 503 Lesson 7 – Discrete Models

The Solutions

LP Solution

roundedLP Solution

IP Solution

x1 x2 x3 x4unit profit 4.8 6.1 4.5 5.2 Maxvariables 0 16.10839 5.788014 15.2615 203.667

sumprod RHSConst 1 1 1 1 1 37.1579 <= 50Const 2 2.3 4.5 6.8 2.5 150 <= 150Const 3 11.3 10.5 9.3 11.6 400 <= 400Const 4 3.4 5.3 2.1 1.8 125 <= 125

x1 x2 x3 x4unit profit 4.8 6.1 4.5 5.2 Maxvariables 0 16 6 15 202.6

sumprod RHSConst 1 1 1 1 1 37 <= 50Const 2 2.3 4.5 6.8 2.5 150.3 <= 150Const 3 11.3 10.5 9.3 11.6 397.8 <= 400Const 4 3.4 5.3 2.1 1.8 124.4 <= 125

x1 x2 x3 x4unit profit 4.8 6.1 4.5 5.2 Maxvariables 0 17 0 19 202.5

sumprod RHSConst 1 1 1 1 1 36 <= 50Const 2 2.3 4.5 6.8 2.5 124 <= 150Const 3 11.3 10.5 9.3 11.6 398.9 <= 400Const 4 3.4 5.3 2.1 1.8 124.3 <= 125

Page 10: ENM 503 Lesson 7 – Discrete Models

Feasible Rounding

feasibleroundedLP Solution

IP Solution

x1 x2 x3 x4unit profit 4.8 6.1 4.5 5.2 Maxvariables 0 16 5 15 198.1

sumprod RHSConst 1 1 1 1 1 36 <= 50Const 2 2.3 4.5 6.8 2.5 143.5 <= 150Const 3 11.3 10.5 9.3 11.6 388.5 <= 400Const 4 3.4 5.3 2.1 1.8 122.3 <= 125

x1 x2 x3 x4unit profit 4.8 6.1 4.5 5.2 Maxvariables 0 17 0 19 202.5

sumprod RHSConst 1 1 1 1 1 36 <= 50Const 2 2.3 4.5 6.8 2.5 124 <= 150Const 3 11.3 10.5 9.3 11.6 398.9 <= 400Const 4 3.4 5.3 2.1 1.8 124.3 <= 125

Page 11: ENM 503 Lesson 7 – Discrete Models

The Assignment Problem

Assign n workers to n tasks

I heard that this is really good!

Page 12: ENM 503 Lesson 7 – Discrete Models

Some Applications

workers to tasks jobs to machines facilities to locations Truck drivers to customer pick-up points Umpire crews to baseball games Judges to court dockets State inspectors to construction sites Weapons to targets

These are some terrific applications.

Page 13: ENM 503 Lesson 7 – Discrete Models

A problem Three workers are to be assigned to one of 4 distinct

tasks. Each worker can perform each task in a different time. The objective is to minimize the total time to complete the assigned tasks.

worker task times

We need to add a dummy worker.

time task1 task2 task3 task4w1 12 13 10 11w2 10 12 14 10w3 14 11 15 12

Page 14: ENM 503 Lesson 7 – Discrete Models

The Knapsack Problem

A total of m items whose weights are a1, a2, …, am are available for packing a knapsack. The total weight to be packed cannot exceed b. The objective is to pack as many items as possible.

m

ii=1

1

0 if itemi is not to be packedLet

1 if itemi is to be packed

Maximize x

subject to: ; 0,1

i

m

i i ii

x

p

a x b x

Page 15: ENM 503 Lesson 7 – Discrete Models

An Example – solver binary solutionValue weight

x1 0 8.5x2 1 3.7x3 1 1.9x4 1 2.8x5 1 4.7x6 0 6.9x7 0 8.7x8 1 3.3x9 0 5.8x10 0 9.1x11 0 7.9x12 0 5.4x13 1 4.1x14 1 3.8x15 0 6.7x16 0 5.4x17 0 8.5x18 0 6.4x19 1 3.4x20 1 2.2sum 9 29.9

<=30

Value weightx1 1 8.5x2 1 3.7x3 1 1.9x4 1 2.8x5 1 4.7x6 0 6.9x7 0 8.7x8 1 3.3x9 0 5.8x10 0 9.1x11 0 7.9x12 1 5.4x13 1 4.1x14 0 3.8x15 0 6.7x16 0 5.4x17 0 8.5x18 0 6.4x19 1 3.4x20 1 2.2sum 10 40

<=40

Value weightx1 0 8.5x2 0 3.7x3 1 1.9x4 1 2.8x5 1 4.7x6 1 6.9x7 0 8.7x8 1 3.3x9 1 5.8x10 0 9.1x11 0 7.9x12 1 5.4x13 1 4.1x14 1 3.8x15 0 6.7x16 1 5.4x17 0 8.5x18 0 6.4x19 1 3.4x20 1 2.2sum 12 49.7

<=50

Page 16: ENM 503 Lesson 7 – Discrete Models

New and Improved Knapsack Problem

Let cj = cost of the ith itemwj = weight of the jth item

vj = volume of the jth item

1

1

1

max

subject to:

n

j ji

n

j jj

n

j jj

p c x

w x Weight

v x Volume

It is comforting to

know my load is

optimal!

Page 17: ENM 503 Lesson 7 – Discrete Models

Example – new and improvedcost Value weight

10.3 x1 0 8.521.3 x2 1 3.745.8 x3 1 1.911.7 x4 1 2.89.8 x5 0 4.75.7 x6 0 6.9

17.3 x7 0 8.714.2 x8 1 3.322.9 x9 0 5.831.7 x10 0 9.140.5 x11 1 7.938.1 x12 1 5.47.8 x13 0 4.1

11.4 x14 0 3.837.1 x15 1 6.740.3 x16 1 5.420.2 x17 0 8.515.6 x18 0 6.49.4 x19 0 3.4

12.8 x20 1 2.2sum 9 39.3

total cost = 261.8 <=40

Page 18: ENM 503 Lesson 7 – Discrete Models

Let’s count the number of solutions…

Dad, how many solutions are there for the knapsack

problem if I have 30 items to consider?

You should know that Johnny. It is 230 or 1,073,741,824

solutions if you include the infeasible ones as well.

Page 19: ENM 503 Lesson 7 – Discrete Models

The Traveling Salesman Problem

There once was a farmer’s daughter…

You got to know the territory!

Page 20: ENM 503 Lesson 7 – Discrete Models

Traveling Salesman Problem

A salesman must visit each of n cities once and only once returning to his starting city. What route should be followed so that the total distance (cost or time) traveled is minimized?

(n-1)! possible routes

ItineraryDaytonCincinnatiDenverNew YorkAtlantaChicagoBostonSan FranciscoWapakoneta

My secretary always finds for

me, the minimum

distance itinerary.

Page 21: ENM 503 Lesson 7 – Discrete Models

A From-to Matrix

From / To

City A City B City C City D

City A 25 30 12

City B 25 17 23

City C 30 17 37

City D 12 23 37

distances in miles

Page 22: ENM 503 Lesson 7 – Discrete Models

Traveling on a network

25

5

3 4

6

7

8

11A

B C

D

E

F

G

6! = 720 routesA solution isa permutation!

Page 23: ENM 503 Lesson 7 – Discrete Models

A Traveling Salesman Problem

P. Rose, currently unemployed, has hit upon the followingscheme for making some money. He will guide a group ofpeople on a tour of all National League baseball parks. Thetour will start and end in Cincinnati. What route should hefollow in order to minimize total distances (costs)?

Page 24: ENM 503 Lesson 7 – Discrete Models

Distances between parks in miles

ATL CHI CIN HOU LA MON NY PHI PIT STL SD SFATL 702 454 842 2396 1196 864 772 714 554 2363 2679CHI 702 324 1093 2136 764 845 764 459 294 2184 2187CIN 454 324 1137 2180 798 664 572 284 338 2228 2463HOU 842 1093 1137 1616 1857 1706 1614 1421 799 1521 2021LA 2396 2136 2180 1616 2900 2844 2752 2464 1842 95 405MON 1196 764 798 1857 2900 396 424 514 1058 2948 2951NYK 864 845 664 1706 2844 396 92 386 1002 2892 3032 PHI 772 764 572 1614 2752 424 92 305 910 2800 2951PIT 714 459 284 1421 2464 514 386 305 622 2512 2646STL 554 294 338 799 1842 1058 1002 910 622 1890 2125SD 2363 2184 2228 1521 95 2948 2892 2800 2512 1890 500SF 2679 2187 2463 2021 405 2951 3032 2951 2646 2125 500

Page 25: ENM 503 Lesson 7 – Discrete Models

Heuristics -algorithm developmentI need a goodheuristic tosolve this problem.

Joe EngineerP. Rose

Heuristic: A procedure for solving problems by an intuitiveapproach in which the structure of the problem can be interpretedand exploited intelligently to obtain a reasonable solution.

Page 26: ENM 503 Lesson 7 – Discrete Models

Nearest Neighbor Heuristic – a greedy heuristic algorithm

ATL CHI CIN HOU LA MON NY PHI PIT STL SD SFATL 702 454 842 2396 1196 864 772 714 554 2363 2679CHI 702 324 1093 2136 764 845 764 459 294 2184 2187CIN 454 324 1137 2180 798 664 572 284 338 2228 2463HOU 842 1093 1137 1616 1857 1706 1614 1421 799 1521 2021LA 2396 2136 2180 1616 2900 2844 2752 2464 1842 95 405MON 1196 764 798 1857 2900 396 424 514 1058 2948 2951NYK 864 845 664 1706 2844 396 92 386 1002 2892 3032 PHI 772 764 572 1614 2752 424 92 305 910 2800 2951PIT 714 459 284 1421 2464 514 386 305 622 2512 2646STL 554 294 338 799 1842 1058 1002 910 622 1890 2125SD 2363 2184 2228 1521 95 2948 2892 2800 2512 1890 500SF 2679 2187 2463 2021 405 2951 3032 2951 2646 2125 500

Page 27: ENM 503 Lesson 7 – Discrete Models

LAX

SNF

CIN

MON

SND

ATL

HOU

CHI PITSTL

PHI

NYK

DISTANCE = 8015 MILES

Page 28: ENM 503 Lesson 7 – Discrete Models

LAX

SNF

CIN

MON

SND

ATL

HOU

CHI PITSTL

PHI

NYK

DISTANCE = 8015 MILES

X

X

OPTIMUM= 7577 MILES

Page 29: ENM 503 Lesson 7 – Discrete Models

Other Applications

manufacture of circuit boards assembly line reconfiguration mixing paints colors in vats searching for stars

Page 30: ENM 503 Lesson 7 – Discrete Models

The Chinese Postman Problem

A study in the optimal delivery of the postal mail

Page 31: ENM 503 Lesson 7 – Discrete Models

The problem defined The Chinese postman problem concerns a postman

who has to deliver mail to houses along each of the streets in a particular housing estate, and wants to minimize the distance that has to be walked.

The problem was first considered by the Chinese mathematician Mei-ko Kwan in the1960s.

Based on this Alan Goldman suggested the name "Chinese Postman problem" to Jack Edmonds when Edmonds was in Goldman's Operations Research group at the U.S. National Bureau of Standards (now NIST). Edmonds appreciated its "catchiness" and adopted it.

Page 32: ENM 503 Lesson 7 – Discrete Models

More of the Chinese Postman ProblemGiven a network with distances assigned to each arc,find the minimum distance walk that walks each arcat least once and returns to the starting node.

25

5

3 4

6

7

8

11A

B C

D

E

F

G

I get tired walking

this route. It is too

long.

Page 33: ENM 503 Lesson 7 – Discrete Models

The Bridges of Königsberg

Königsberg (Kaliningrad) was a city in Prussia situated on the Pregel River, which served as the residence of the dukes of Prussia in the 16th century. 

The river Pregel flowed through the town, creating an island.  Seven bridges spanned the various branches of the river, as shown.

Page 34: ENM 503 Lesson 7 – Discrete Models

Graph Theory and the Bridges of Königsberg A famous problem concerning Königsberg was whether it

was possible to take a walk through the town in such a way as to cross over every bridge once, and only once.  An example of a failed attempt to take such a walking tour is shown below.

How many bridges must I cross?

Page 35: ENM 503 Lesson 7 – Discrete Models

Now comes Euler This problem was first solved by the Swiss mathematician

Leonhard Euler who invented the branch of mathematics now known as graph theory in the process of his solution.

Euler's approach was to regard the spots of land (there are 4 of them) as points to be visited, and the bridges as paths between those points.  The mathematical essentials of the map of Königsberg can then be reduced to the following diagram, which is an example of what is called a graph:

Page 36: ENM 503 Lesson 7 – Discrete Models

Leonhard Euler Euler was the most prolific writer of

mathematics of all time. He made large bounds forward in the study of modern analytic geometry and trigonometry where he was the first to consider sin, cos etc. as functions rather than as chords.

He made decisive and formative contributions to geometry, calculus and number theory. He integrated Leibniz's differential calculus and Newton's method of fluxions into mathematical analysis. He introduced beta and gamma functions, and integrating factors for differential equations.

He studied continuum mechanics, lunar theory, the three body problem, elasticity, acoustics, the wave theory of light, hydraulics, and music. He laid the foundation of analytical mechanics.

Born: 15 April 1707 in Basel, SwitzerlandDied: 18 Sept 1783 in St Petersburg, Russia

Page 37: ENM 503 Lesson 7 – Discrete Models

Network Terminology Graph – a finite set of points (vertices or nodes)

together with a finite set of connecting links called edges (arcs or branches). Each edge connects two different vertices

Path – a sequence of edges in a graph where consecutive edges have the same vertex. Circuit – a path which starts and ends at the same

vertex Euler circuit – a circuit in which each edge of the graph

is used exactly once

Page 38: ENM 503 Lesson 7 – Discrete Models

Euler's Solution When a vertex is "visited" in the middle of the

process of tracing a graph, there must be an edge coming into the vertex, and another edge leaving it; and so the order of the vertex must be an even number. 

This must be true for all but at most two of the vertices--the one you start at, and the one you end at

A connected graph is traversible if and only if it has at most two vertices of odd order.  (the starting and ending vertices may be the same, in which case the order of every vertex must be even.) 

The Königsberg graph shows that there are more than two vertices of odd order, and so the desired walking tour of Königsberg is impossible.

Page 39: ENM 503 Lesson 7 – Discrete Models

Euler Solution If there are no odd nodes in the network, the network

is certainly traversable. The minimum distance is the sum of the arc

distances and any Eulerian trail is an acceptable shortest route, so the problem is trivial.

If a Euler circuit does not exist, then the problem is to find a circuit that covers all the edges of a given graph with the minimum number of duplications.

If v0 is the number of odd-ordered vertices, then no fewer than v0 / 2 additional edges are necessary.

Page 40: ENM 503 Lesson 7 – Discrete Models

Other Applications

delivery mail, newspaper, door-to-door soliciting

trash pickup snow plowing and salting streets, street

cleaning railroad track inspections and maintenance meter reading school bus routes

Page 41: ENM 503 Lesson 7 – Discrete Models

Play ball! Now it’s your turn.

The Department of Engineering Management & Systems has proudly presented Discrete Models

and Methods