1 the primal-dual algorithm 1 2 efficiently ...web.mat.bham.ac.uk/p.butkovic/3m02b/3m02b transp...

210
1 1 THE PRIMAL-DUAL ALGORITHM 1 1.1 Revision of Duality in Linear Programming 3 1.2 The Primal-Dual Algorithm 14 2 EFFICIENTLY SOLVABLE PROBLEMS 29 2.1 Max-Flow Problem in Networks 33 2.2 Application of the Primal-Dual Algorithm to the Transportation Problem 83 2.3 Introduction to the Theory of Matroids 123 3 HARD PROBLEMS 173 3.1 On the NP -completeness 173 3.2. Algorithms for NP -complete Problems 189

Upload: others

Post on 29-Jan-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

  • 1

    1 THE PRIMAL-DUAL ALGORITHM 1

    1.1 Revision of Duality in Linear Programming 3

    1.2 The Primal-Dual Algorithm 14

    2 EFFICIENTLY SOLVABLE PROBLEMS 29

    2.1 Max-Flow Problem in Networks 33

    2.2 Application of the Primal-Dual Algorithm to the Transportation Problem 83

    2.3 Introduction to the Theory of Matroids 123

    3 HARD PROBLEMS 173

    3.1 On the NP -completeness 173

    3.2. Algorithms for NP -complete Problems 189

  • 2

  • 3

    1 The primal-dual algorithm

    1.1 Revision of Duality in Linear Programming

    General LP:

    f (x) = c1x1 + c2x2 + … + cnxn → min or max

    subject to (s.t.)

    ai1x1 + ai2x2 + … + ainxn {≤, ≥, =} bi (i = 1, ..., m)

    x1, x2, … , xp ≥ 0

    Example 1.1.1

    3x1 – 2x2 → max

    s.t.

    2x1 + 5x2 ≥ 17

    3x1 – 5x2 = –27

    x1 – x2 ≤ 20

    x2 ≥ 0

    W.l.o.g. :

    c1x1 + c2x2 + … + cnxn → min

    ai1x1 + ai2x2 + … + ainxn = bi (i = 1, ..., m)

    x1, x2, …, xn ≥ 0

  • 4

  • 5

    f(x) = cTx → min

    Ax = b

    x ≥ 0

    f (x) … objective function

    Here

    A = (aij) ∈ Rm×n

    c = (c1, … , cn)T∈Rn

    b = (b1, … , bm)T∈Rm

    x = (x1, … , xn)T∈Rn

    M = { x ∈Rn; Ax = b, x ≥ 0 } ……

    …… set of feasible solutions

    Mopt = { x ∈M; cTx ≤ cTz for all z ∈M } ……

    …… set of optimal solutions

    Theorem 1.1.1 (Fundamental Theorem of LP)

    For every LP one of the following holds:

    (i) LP is infeasible (i.e. M = Ø),

    (ii) LP has an optimal solution (Mopt ≠ Ø),

    (iii) )(min xfMx∈

    = –∞ .

    (SLP)

  • 6

  • 7

    Definition of the dual problem:

    f (x) = cTx → min g(π) = πTb → max

    iTi bxa = i∈I πi ≥≤ 0

    iTi bxa ≥ i∈ I πi ≥ 0

    xj ≥ 0 j∈J πTAj ≤ cj

    xj ≥≤ 0 j∈J πTAj = cj

    ( )JjAJjAIia

    IiaA jjT

    i

    Ti ∈∈=

    ∈∈

    = ,,,

    ,

    Example 1.1.2:

    f(x) = 3x1 – 4x2 → min g(π) = 5π1 + 7π2→ max

    s.t. s.t.

    2x1 – 7x2 ≥ 5 2π1 + 3π2 = 3

    3x1 + x2 = 7 –7π1 + π2 ≤ –4

    x2 ≥ 0 π1≥ 0

    primal dual

  • 8

  • 9

    Theorem 1.1.2 (On Symmetry)

    Dual to the dual is the primal.

    MP [optPM ] … set of feasible [optimal] solutions

    to the primal LP

    MD [optDM ] … set of feasible [optimal] solutions

    to the dual LP

    Theorem 1.1.3 (Weak Duality Theorem)

    (∀x∈MP)(∀π∈MD) cTx ≥ πTb.

    Corollary 1: If x∈MP, π∈MD, cTx = πTb then optD

    optP , MMx ∈π∈ .

    Corollary 2:

    (a) If −∞=∈

    xcT

    Mx P

    min then MD = Ø.

    (b) If +∞=π∈π

    bT

    M D

    max then MP = Ø.

    Theorem 1.1.4 (Strong Duality Theorem) opt

    MP ≠ Ø if and only if opt

    MD ≠ Ø. If an optimal

    solution exists then .maxminDP

    bxcT

    M

    T

    Mxπ=

    ∈π∈

  • 10

  • 11

    Corollary: For every primal-dual pair exactly

    one of the possibilities in the table below occurs:

    optPM ≠ Ø min cTx = –∞ MP = Ø

    optD M ≠ Ø

    max πTb = +∞

    MD = Ø

    Important primal-dual pairs

    f(x) = cTx → min g(π) = πTb → max

    Ax ≥ b πTA ≤ cT

    x ≥ 0 π ≥ 0

    (CLP) “Symmetric pair”

    f(x) = cTx → min g(π) = πTb → max

    Ax = b πTA ≤ cT

    x ≥ 0

    (SLP)

  • 12

  • 13

    cTx → min πTb → max

    iTi bxa = i∈I πi ≥≤ 0

    iTi bxa ≥ i∈ I πi ≥ 0

    xj ≥ 0 j∈J πTAj ≤ cj

    xj ≥≤ 0 j∈J πTAj = cj

    Important task: Find an optimal solution to the

    dual only using the information about the

    primal optimal solution.

    Theorem 1.1.5 (Complementary Slackness)

    Suppose x∈MP, π∈MD.

    Then x∈ optMP and π∈opt

    MD if and only if

    (cj – πTAj )xj = 0 = πi ( Tia x – bi) for all i and j.

    [End of sample. You can download more pages from CANVAS]

  • 14

  • 15

    1.2 The Primal-Dual Algorithm

    cTx → min πTb → max

    Ax = b πTA ≤ cT

    x ≥ 0

    (P) (D)

    W.l.o.g. b ≥ 0.

    cTx → min πTb → max

    iTi bxa = i∈I πi ≥≤ 0

    iTi bxa ≥ i∈ I πi ≥ 0

    xj ≥ 0 j∈J πTAj ≤ cj

    xj ≥≤ 0 j∈J πTAj = cj

    By the Complementary Slackness:

    Optimality conditions for x∈MP, π∈MD:

    (cj – πTAj)xj = 0 = πi( Tia x – bi) for all i and j.

    Equivalently:

    (cj – πTAj)xj = 0 for all j ( 1.1)

  • 16

  • 17

    An essential assumption:

    Suppose at least one π ∈MD is known.

    (Thus cj – πTAj ≥ 0 for all j) .

    x = ? (cj – πTAj > 0 ⇒ xj = 0) for every j (*)

    (then this x (and also π) would be optimal).

    Figure 1.2.1

    Start by any π∈MD (set π = 0 if c ≥ 0)

    ∴ πTAj ≤ cj for all j

    J = { j; πTAj = cj }

    Primal Dual Restricted primal (find x*

    satisf. (*))

    Dual of the restricted

    primal

    Adjustment to π

    π

    Stop success

    fail

  • 18

  • 19

    By the Complementary Slackness Theorem: If

    we find x∈MP, xj = 0 for all j∉J then x is

    optimal.

    Therefore we need to find x such that

    ∑∈

    =Jj

    ijij bxa , i = 1, ... , m

    ( 1.2 )

    xj ≥ 0 , j∈J

    J …. the set of admissible columns (indices)

    To search for such an x, we create a new LP,

    called the restricted primal (RP):

    ξ = ∑=

    m

    i

    aix

    1

    → min

    ∑∈

    =+Jj

    iaijij bxxa i = 1, ..., m

    xj ≥ 0 j∈J

    0≥aix i = 1, ..., m

    aix (i = 1, ..., m) ……. artificial variables

    Note: (1.2) has a solution ⇔ ξopt = 0

    (RP)

  • 20

  • 21

    If ξopt = 0 , then all aix = 0 ∴ x optimal

    If ξopt > 0 then consider the dual of the

    restricted primal (DRP), which is:

    w = πTb → max

    πTAj ≤ 0, j ∈J (DRP)

    πi ≤ 1, i = 1, ..., m

    π …. an optimal solution to (DRP)

    Then by the SDT we have:

    πTb = ξopt > 0 ( 1.3)

    “Correction” of π, using π

    π* = π + θπ, where θ = ?

    (a) π*T b > πT b or, equivalently,

    πT b + θπT b > πT b

    ∴ θ > 0

  • 22

  • 23

    (b) To guarantee (dual) feasibility of π*:

    π*TAj ≤ cj, j = 1, ..., n

    or, equivalently,

    πTAj + θπTAj ≤ cj, j = 1, ..., n .

    We set:

    >ππ

    π−0j

    T

    jT

    jT

    jA

    A

    Acmin

    def

    = θ1 (1.4)

    Clearly, θ1 > 0 and the new cost is

    w* = πT b + θ1 bTπ > w = πT b

    Next step: Redefine the set J and repeat the

    procedure until either ξopt = 0 and optimality in

    P is reached.

    But what if πTAj ≤ 0 for all j? We show in

    Theorem 1.2.1 that then P is infeasible.

    Theorem 1.2.1

    (Infeasibility in the primal-dual algorithm): If

    (1) ξopt > 0 and

    (2) πTAj ≤ 0 for all j ∉ J

    then P is infeasible. Proof: →→→

  • 24

  • 25

    The primal-dual algorithm

    Primal Dual Restricted primal

    π := π + θ1 π

    π

    Dual of restricted primal

    J = {j; πTAj = cj}

    ξopt = 0

    stop

    ξopt > 0

    πTAj ≤ 0

    for all j∉J

    MP = Ø

    ∃ j∉J: πTAj > 0

  • 26

  • 27

    The primal-dual algorithm – basic scheme

    The primal-dual algorithm – detailed scheme

    Primal Dual Restricted primal

    Adjustment to π

    π x

    Given is P

    cTx → min Ax = b

    x ≥ 0

    Take π feasible to D πTb → max πTA ≤ cT

    Dual of restricted

    primal

  • 28

  • 29

    J := { j; πTAj = cj }

    Solve RP

    ξ = ∑=

    m

    i

    aix

    1

    → min

    ∑∈

    =+Jj

    iaijij bxxa i = 1, ..., m

    xj ≥ 0 j∈ J 0≥aix i = 1, ..., m

    ξopt = 0

    ∃ j∉J: πTAj > 0

    θ1 :=

    >ππ

    π−0j

    T

    jT

    jT

    jA

    A

    Acmin

    π := π + θ1π

    Find π optimal to DRP

    yes

    yes

    no

    no

    x is optimal to P

    P is infeasible

  • 30

  • 31

    Example:

    6x1 + 16x2 – 15x3 → min

    s.t.

    2x1 – 4x2 + x3 = 1

    x1 + 5x2 – 5x3 = 2

    x1-3 ≥ 0

    Solve by the PDA starting from π = (0, 3)T.

  • 32

  • 33

    2 Efficiently solvable problems

    2.1 Max-Flow Problem in Networks

    2.1.1 Introduction

    Example 2.1.1

    Sunco Oil want to ship the maximum possible

    amount of oil per hour via the pipeline from

    node s to node t in Figure 2.1.1. On its way

    from node s to node t, oil must pass through

    some or all of stations a, b, and c. The various

    arcs in Figure 2.1.1 represent pipes of different

    diameters. The maximum number of barrels of

    oil [millions of barrels] per hour that can be

    pumped through each arc is indicated in

    rectangles at each arc (“arc capacity”).

  • 34

  • 35

    Figure 2.1.1

    Maximum-flow problem (informally): to achieve

    the maximum amount of flow from a starting

    point (source s) to a terminal point (sink t).

    s b

    c

    t

    a

    5

    2

    4 2

    4

    1

  • 36

  • 37

    2.1.2 Directed graphs (digraphs) and flows

    Digraph is D = (V, E) where

    • V ≠ Ø is a finite set (set of nodes / vertices)

    • E ⊆ V × V ={(u, v); u, v∈V} (set of arcs /edges)

    Note that (u, v) ≠ (v, u).

    (u, v) ∈E ….. u, v are adjacent

    Usually: V = {v1, …, vm}, V = m

    E = {e1, …, en}, E = n

    A digraph (V, E) is called oriented if for every u,

    v ∈ V we have: (u, v) ∈ E ⇒ (v, u) ∉ E.

    Network is N = (V, E, s, t, b), where (V, E) is an

    oriented digraph without loops, s∈V has no

    incoming arcs, t ∈V has no outcoming arcs and

    b: E → R+ ∪ {∞}.

    b(i, j) or only bij ….. capacity of the arc (vi, vj).

  • 38

  • 39

    If E = {e1, … , en}, then bk will stand for b(ek).

    f: E → R+ is a flow in N if

    (1) 0 ≤ f ≤ b (capacity constraints)

    (2) ∑∑∈∈

    =ExyyEyxy

    xyfyxf),(:),(:

    ),(),( holds

    for all x∈V, x ≠ s, x ≠ t (conservation law)

    Convention: fij and fk

    ∑∑ =xek

    xek

    kk

    ff enters leaves

    for all x∈V, x ≠ s, x ≠ t.

    ∑=sek

    k

    fv leaves

    ….. the value of the flow f, notation

    v(f) or just v.

    Max-Flow Problem (MFP)

    Given a network, find a flow (“maximal flow”)

    in this network whose value is maximal.

  • 40

  • 41

    Example 2.1.1 (cont.):

    Conventions:

    Free-standing numbers … flow values

    Other numbers … capacities

    s b

    c

    t

    a

    5

    2

    4 2

    4

    1

    1

    2 1 1

    2 2

  • 42

  • 43

    2.1.3 MFP is a linear program

    Let D = (V, E) be a digraph without loops.

    V = {v1, … ,vm}, E = {e1, … , en}.

    AD = (aij) ∈ Rm×n is called the node-arc incidence

    matrix of D if

    1, if ej is leaving vi,

    aij = -1, if ej is entering vi,

    0, otherwise.

    Example 2.1.2

    s

    b

    t

    a

    e1

    e2 e5

    e3

    e4

  • 44

  • 45

    Structure of node-arc incidence matrices:

    Each column contains exactly one 1 and one –1

    since every arc is leaving one node and entering

    one node.

    Let N = (V, E, s, t, b) be a network and A be

    the node-arc incidence matrix of N. Let f be a

    flow in N.

    Consider the sum jj

    ij fa∑ for a fixed index i:

    ∑∑∑ −=ijij xe

    j x e

    jjj

    ij fffaentering is leaving is

    = 0,

    if xi ∉{s, t};

    vffaij x e

    jjj

    ij == ∑∑leaving is

    , if xi = s ;

    vffaij x e

    jjj

    ij ′=−= ∑∑entering is

    , for some v′ ,

    if xi = t.

    ∴ Af = (0, …, v, … , v′ , …, 0)T

    Add up all equations:

    vv ′+=0 ∴ vv −=′

  • 46

  • 47

    Therefore the system of equations has the form:

    Af + dv = 0,

    where d =

    1

    1

    Other conditions on f :

    f ≤ b, f ≥ 0

    Theorem 2.1.1 If A is a node-arc incidence

    matrix of the network N = (V, E, s, t, b) then

    f: E → R+ is a flow in N if and only if it

    satisfies the conditions

    Af + dv = 0

    f ≤ b

    f ≥ 0

    and so the MFP in N is equivalent to the LP

    … s

    … t

  • 48

  • 49

    v → max

    s.t.

    Af + dv = 0

    f ≤ b

    f ≥ 0

    Note: (Here m is the number of nodes and n is

    the number of arcs)

    ♦ (MFP) has n + 1 variables f1, …, fn, v and

    m + n non-trivial constraints (m equations

    and n inequalities).

    ♦ v can be assumed to be non-negative without

    loss of generality.

    ♦ f = 0 (with v = 0) is always a feasible solution,

    and thus it is a flow in any network.

    Corollary: A maximal flow exists in every

    network with finite capacities of arcs leaving the

    source (or entering the sink) – this will be

    assumed from now on.

    Proof: → → →

    (MFP)

  • 50

  • 51

    Example 2.1.3:

    s b

    c

    t

    a

    1

    2

    2 2

    3

    1

  • 52

  • 53

    2.1.4 The Ford and Fulkerson algorithm for

    solving the MFP

    Example 2.1.3 (contd.):

    s b

    c

    t

    a

    1

    2

    2 2

    3

    1

    1

    1 0 1

    1 1

  • 54

  • 55

    Observation:

    An “augmenting path” has one or both of the

    two types of arcs:

    ♦ forward arcs whose direction is the same as

    that of the path and the flow is strictly less

    than the capacity of arc;

    ♦ backward arcs whose direction is opposite and

    the flow is positive.

    s b

    c

    t

    a

    1

    2

    2 2

    3

    1

    0

    2 2 0

    2 2

  • 56

  • 57

    Definition of an augmenting path

    Given a network N = (V, E, s, t, b), and a flow

    f, an augmenting path p is a path from s to t

    in the undirected graph resulting from (V, E) by

    ignoring arc directions, with the following

    properties:

    ♦ For every arc (i, j) that is traversed by p in

    the forward direction (“forward arc”), we

    have f(i, j) < b(i, j). That is, forward arcs are

    unsaturated.

    ♦ For every arc (i, j) that is traversed by p in

    the reverse direction (“backward arc”), we

    have f(i, j) > 0. That is backward arcs are

    non-empty.

  • 58

  • 59

    Using an augmenting path

    How to find a flow of a bigger value (if an

    augmenting path is known):

    ♦ increase the flow value on every forward arc

    but still satisfying the capacity constraint and

    ♦ decrease the flow value on every backward arc

    but keeping it ≥ 0.

    The maximum amount of flow augmentation

    possible along p is

    b(i, j) – f(i, j) along a forward arc

    δ = pji on ),(

    min

    f(j, i) along a backward arc

  • 60

  • 61

    How to find an augmenting path

    A systematic way of finding an augmenting

    path:

    Start by f = 0 (or other flow).

    Propagate labels from node s until we reach

    node t or get stuck. Each node x will have

    assigned to it a two-part label:

    label(x) := (L1[x], L2[x])

    Here

    L1[x] ….. from where x was labelled

    L2[x] ….. the amount of extra flow that can be

    “brought” to x from s.

    Labelling outward from a node x: “scanning x”

    label(s) := (∅, +∞)

  • 62

  • 63

    Scanning from a node x:

    For every unlabelled node y adjacent to x

    distinguish two cases:

    Case 1: (x, y) ∈ E

    Label y if f (x, y) < b(x, y)

    L1[y] := x

    L2[y] := min {L2[x], b(x, y) – f(x, y)}

    y

    x

    (L1[x], L2[x] )

    (x, min{L2[x], b(x,y) – f(x,y)})

    f(x,y) < b(x,y)

  • 64

  • 65

    Case 2: (y, x) ∈ E

    Label y if f(y, x) > 0

    L1[y] := –x

    L2[y] := min {L2[x], f(y, x)}

    y

    x

    (L1[x], L2[x] )

    (–x, min{L2[x], f(y, x)})

    f (y, x) > 0

  • 66

  • 67

    LIST … the set of nodes that are labelled but not

    scanned yet

    The labelling algorithm:

    (1) LIST := { s }.

    (2) Repeat until LIST = Ø:

    Select a node x from LIST,

    remove x from LIST,

    scan x, and

    add all nodes labelled from x to LIST.

    Termination of the labelling algorithm:

    ♦ either t gets labelled: reconstruct an

    augmenting path backwards from t using

    L1’s and augment the flow along the

    augmenting path by δ = L2(t), that is,

    fj → fj’ =

    δ−δ+

    arcbackward

    arcforward

    ,f

    ,f

    j

    j

    ♦ or LIST becomes empty: flow is optimal (to be

    proved later on).

  • 68

  • 69

    When we achieve optimality after an application

    of FFA to MFP, we say we are at a

    nonbreakthrough.

    Example 2.1.4: Apply FFA to solve MFP in the

    network below starting from the given flow:

    s b

    c

    t

    a

    2

    2

    3 2

    3

    2

    0

    2

    2

    2

    2

    0

  • 70

  • 71

    FORD AND FULKERSON ALGORITHM

    (FFA)

    Input: A network N = (V, E, s, t, b)

    Output: A maximum flow f in N

    f: = 0 (or any other flow if known)

    again: delete all existing labels (if any)

    LIST := {s}, label(s) := (Ø, +∞)

    while LIST ≠ Ø do

    begin

    take any x∈LIST;

    remove x from LIST;

    scan x;

    extend LIST by all nodes scanned from x

    if t is labelled then

    begin

    augment flow f along augmenting path

    by δ = L2(t);

    go to again

    end

    end

  • 72

  • 73

    ♦ If FFA terminates, does it find a maximal flow

    (correctness)?

    ♦ Does FFA terminate?

    ♦ Correctness of FFA

    Let N = (V, E, s, t, b) be a network.

    An s-t cut in N is (W, W ), where

    V = W ∪W ,

    W ∩W = Ø,

    s ∈W, t ∈W .

    The capacity of the cut (W, W ) is

    c(W, W ) = ∑{b(x, y); x ∈W, y ∈W , (x, y) ∈E}.

    W

    s

    W

    t

  • 74

  • 75

    Example (2.1(c) in problem sheets):

    For each cut ),( WW , find c(W, W ),

    ∑∈∈ WyWx

    yxf,

    ),( and ∑∈∈ WyWx

    yxf,

    ),( .

    Lemma: For any cut (W, W ) and flow f the

    following relation holds:

    v(f) = ∑∑∈

    ∈∈∈

    ∈∈−

    EyxWyWx

    EyxWyWx

    yxfyxf

    ),(,

    ),(,

    ),(),( .

    Proof: →→→

    3 8

    6 2

    s

    a

    b

    t 6 3

    2

    5

    0 3 5

    2

  • 76

  • 77

    Theorem 2.1.2 (Min-Cut, Max-Flow)

    (a) The relation v(f ) ≤ c(W, W ) holds for

    every flow f and every cut (W, W ).

    (b) The value of a maximal flow is equal to the

    capacity of a minimal cut.

    Proof : →→→

    W*

    s

    *W

    t

    Labelled nodes Unlabelled nodes

  • 78

  • 79

    Theorem 2.1.3 (Ford-Fulkerson)

    If FFA terminates, it does so at an optimal flow.

    Proof : →→→

    Example 2.1.5:

    s b

    c

    t

    a

    1

    2

    3 2

    3

    1

    1

    2 1 1

    2 2

    (Ø,+∞)

    (s,1)

    (c,1)

    W

  • 80

  • 81

    ♦ Termination of FFA

    Theorem 2.1.4: If the capacities in MFP are

    integers then FFA will terminate after a finite

    number of steps if it starts with an integral flow.

    Proof: → → →

    Corollary: If the capacities in MFP are rational

    numbers then the MFP is solvable using the

    FFA in a finite number of steps.

    Proof: → → →

    Note (following from the construction of flows in

    FFA): If the capacities in (MFP) are integers,

    FFA starts from an integral flow then it finds an

    integral max flow.

    In general (for real capacities):

    • FFA may not terminate.

    • FFA may converge to a flow value strictly less

    than optimal!

    Modifications of FFA which finitely terminate

    after a polynomial number of steps (Karzanov).

  • 82

  • 83

    (ai) Ai

    Bj (bj)

    cij

    xij = ?

    2.2 Application of the Primal-Dual Algorithm to

    the Transportation Problem

    Transport of a single type of product that can be

    arbitrarily divided (oil, flour, coal or electricity).

    Given are:

    • Producers A1, …, Am with capacities a1, …, am.

    • Customers B1, …, Bn with demands b1, …, bn.

    • Unit transportation costs cij (from Ai to Bj) for

    every i = 1, …, m; j = 1, …, n.

    Wanted:

    • The amount of product to be transported

    from Ai to Bj for every i = 1, …, m and

    j = 1, …, n [transportation plan] which

    minimises the total cost of the transport and

    meets the capacity and demands constraints.

  • 84

  • 85

    (ai) Ai

    Bj (bj)

    cij

    xij = ?

    Transportation table (TT)

    Demands C

    ap

    aci

    ties

    Unit costs and/or amount of transported products

    bj

    …..

    ai ………….. xij or cij

    Cell (i, j) ↔ Arc AiBj Row i ↔ Producer Ai

    Column j ↔ Customer Bj

    cell (i, j)

  • 86

  • 87

    Example 2.2.1:

    Powerco has 3 electric power plants that supply power for 4 cities. The table below shows capacities of the plants in 106 kWh, peak power demands of the cities and the costs [£1,000] of sending 106 kWh from plants to cities. Find the distribution of the electricity minimising the cost and meeting each city’s peak power demand.

    Demands→ 45 20 30 30 Capacities

    35 8 6 10 9

    50 9 12 13 7

    40 14 9 16 5

    GREEDY:

    45 20 30 30

    35

    50

    40

    Cost:

  • 88

  • 89

    TP as an optimisation problem:

    ∑∑= =

    →m

    i

    n

    jijij xc

    1 1

    min

    subject to

    ∑=

    =n

    jiij ax

    1

    (i = 1, ..., m) (A)

    ∑=

    =m

    ijij bx

    1

    (j = 1, ..., n) (B)

    xij ≥ 0 (i = 1, ..., m, j = 1, ..., n) (C)

    W.l.o.g.: ai > 0, bj > 0 for all i, j.

    ∑∑= =

    m

    i

    n

    jijij xc

    1 1

    …… objective function.

    X = (xij) satisfying (A), (B) and (C) is a feasible

    solution.

    A feasible solution minimising the objective

    function is called an optimal solution.

  • 90

  • 91

    Theorem 2.2.1: TP has an optimal solution if it

    has a feasible solution.

    Theorem 2.2.2: TP has a feasible solution if and

    only if ∑ ∑= =

    =m

    i

    n

    jji ba

    1 1

    .

    ∑ ∑= =

    =m

    i

    n

    jji ba

    1 1

    … TP is balanced

    If ∑ ∑= =

    <m

    i

    n

    jji ba

    1 1

    then a dummy producer Am+1

    is introduced with the capacity

    am+1 = ∑ ∑= =

    −n

    j

    m

    iij ab

    1 1

    and costs

    cm+1,j = 0 ( j = 1, ..., n).

    ∴ We may assume w.l.o.g. : TP is balanced (and

    therefore has a feasible and optimal solution).

    Now apply the primal-dual algorithm to TP.

  • 92

  • 93

    ∑∑= =

    →m

    i

    n

    jijij xc

    1 1

    min

    subject to

    ∑=

    =n

    jiij ax

    1

    (i = 1, ..., m)

    ∑=

    =m

    ijij bx

    1

    ( j = 1, ..., n)

    xij ≥ 0 (i = 1, ..., m, j = 1, ..., n)

    is in standard form - consider it as P in the

    primal-dual algorithm.

    Construction of the dual.

    Two types of equations → use two types of

    variables: αi’s and βj’s.

    w = ∑ ∑= =

    β+αm

    i

    n

    jjjii ba

    1 1

    → max

    s.t.

    αi + βj ≤ cij for all i = 1, ..., m and j = 1, ..., n.

    (P)

    (D)

  • 94

  • 95

    A feasible solution to the dual:

    αi = 0 for all i = 1, ..., m;

    βj = min{cij ; i = 1, ..., m}, for j = 1, …, n.

    I = {1, ..., m}, J = {1, ..., n}

    Convention: “node Ai” → “node i”, similarly

    for Bj.

    i

    j αi + βj ≤ cij

  • 96

  • 97

    Construction of RP.

    IJ = {(i, j) ∈ I × J; αi + βj = cij}.

    Thus, RP is

    ξ = ∑+

    =

    nm

    i

    aix

    1

    → min

    ∑∈

    =+IJjij

    iaiij axx

    ),(:

    i = 1, ..., m

    ∑∈

    + =+IJjii

    ja

    jmij bxx),(:

    j = 1, ..., n

    xij ≥ 0 (i, j) ∈ IJ

    0≥aix i = 1, ..., m + n

    How to solve (RP): Transform to an equivalent

    (RP’) by eliminating all aix :

    Add up all equations in RP:

    ξ = ∑ ∑ ∑= = ∈

    −+m

    i

    n

    j IJjiijji xba

    1 1 ),(

    2 ( 2.1)

    (RP)

  • 98

  • 99

    ∴ RP can be written equivalently as:

    g(x) = ∑∈IJji

    ijx),(

    → max

    ∑∈

    ≤IJjij

    iij ax),(:

    i = 1, ..., m

    ∑∈

    ≤IJjii

    jij bx),(:

    j = 1, ..., n

    xij ≥ 0 (i, j) ∈ IJ

    RP’ ≡ MFP of Fig. 2.2.1, where:

    AiBj is an arc ⇔ (i, j) ∈ IJ

    (RP’)

    ⋮ ⋮

    ⋮ ⋮

    s t

    Admissible arcs

    N

    A1

    A2

    Ai

    Am

    B1

    B2

    Bj

    Bn Figure 2.2.1

    a1

    a2

    ai

    am

    b1

    b2

    bj

    bn

    +∞ +∞

    +∞

    +∞

    +∞

    +∞

  • 100

  • 101

    Lemma 1:

    (a) If f is a flow in N and xij = f(i, j), (i, j) ∈ IJ

    then x = (xij) ∈MRP’ and g(x) = v(f).

    (b) If x = (xij) ∈MRP’ ,

    f(i, j) = xij ((i, j) ∈ IJ),

    f(s, i) = ∑∈IJjij

    ijx),(:

    (i = 1,…, m),

    f(j, t)= ∑∈IJjii

    ijx),(:

    (j = 1, …, n),

    then f is a flow in N and v(f) = g(x).

    Proof: → → →

    Lemma 1 shows that RP for TP is MFP of

    Fig.2.2.1.

    In PDA we need next to check whether ξopt > 0

    or ξopt = 0.

  • 102

  • 103

    How to check ξopt = 0:

    (2.1) was: ξ = ∑ ∑ ∑= = ∈

    −+m

    i

    n

    j IJjiijji xba

    1 1 ),(

    2

    Hence by Lemma 1:

    ξ = ∑ ∑= =

    −+m

    i

    n

    jji fvba

    1 1

    )(2 = ∑=

    −m

    ii fva

    1

    )(22

    ξ = 0 ⇔ v(f) = ∑=

    m

    iia

    1

    (recall that v(f) = ∑=

    m

    i

    isf1

    ),( and f(s, i) ≤ ai, ∀i)

    or, equivalently:

    ξ = 0 ⇔ f(s, i) = ai for all i

    We can now apply FFA to this MFP.

    1. If f(s, i) = ai for all i then ξ = 0

    ∴ x = (xij) is optimal and conversely;

    xij = else,0

    ),(if),,( IJjijif ∈

    2. If f(s, i) < ai for some i. Need optimal

    solution, say βα, , of the dual to the

    restricted primal.

  • 104

  • 105

    Finding βα, :

    At nonbreakthrough, we denote

    I* = { i ∈ I; node i is labelled },

    J* = { j ∈ J; node j is labelled }.

    Lemma 2: At nonbreakthrough the implication

    i ∈I* ⇒ j ∈J*

    holds for every (i, j) ∈IJ.

    Proof: →→→

  • 106

  • 107

    Theorem 2.2.3: At nonbreakthrough, an optimal

    solution to DRP is given by

    1=αi i ∈I*,

    1−=αi i ∉I*,

    1−=β j j ∈J*,

    1=β j j ∉J*.

    Proof: In two steps:

    (a) We show that ( )βα, is a feasible solution to the DRP.

    (b) We show that the objective function value at

    ( )βα, is also attained in the RP.

    The statement will then follow from the duality

    theory.

    →→→

  • 108

  • 109

    ( )βα, ……. optimal solution to DRP Case 1: 0≤β+α ji for all (i, j) ∉ IJ – this

    means that (P) is infeasible – impossible in TP.

    Case 2: 0>β+α ji for at least one (i, j) ∉ IJ –

    in this case θ1 and an update of π are

    computed as follows:

    θ1 = =

    >β+αβ+α

    β−α−0min ji

    ji

    jiijc

    =

    ∉∈β−α−

    **,2

    min JjIic jiij

    ( 2.2)

  • 110

  • 111

    The update of π:

    αi + θ1, if i∈I*

    αi := αi + θ1 iα = ( 2.3)

    αi – θ1, if i∉I*

    βj – θ1, if j∈J*

    βj := βj + θ1 jβ = ( 2.4)

    βj + θ1, if j∉J*

  • 112

  • 113

    Algorithm ALPHABETA

    Transportation problem with inputs cij, ai, bj

    αi := 0 for i = 1, ..., m; βj := min{cij; i = 1, ..., m} for j = 1, ..., n.

    IJ := {(i, j)∈I × J; αi + βj = cij}

    Using FFA solve MFP of Figure 2.2.1 with the set of admissible arcs IJ.

    If (∀i) f(s, i) = ai x is optimal

    Let I* and J* be the sets of labelled nodes

    at nonbreakthrough. Find θ1 and update (α, β) using (2.2), (2.3) and (2.4).

    yes

    no

  • 114

  • 115

    Extended transportation table:

    Demands C

    ap

    aci

    ties

    Unit costs and/or amount of transported goods

    Du

    al

    va

    ria

    ble

    s α

    i

    Dual variables βj

    bj

    ai cij or xij αi

    βj

    cell (i, j)

  • 116

  • 117

    Example 2.2.2:

    Powerco has 3 electric power plants that supply power for 4 cities. The table below shows capacities of the plants in 106 kWh, peak power demands of the cities and the costs [£1,000] of sending 106 kWh from plants to cities. Find the distribution of the electricity minimising the cost and meeting each city’s peak power demand.

    Demands→ 45 20 30 30 Capacities

    35 8 6 10 9

    50 9 12 13 7

    40 14 9 16 5

    Initialization:

    α = (0, 0, 0)T; β = (8, 6, 10, 5)T.

    45 20 30 30

    35 8 6 10 9

    50 9 12 13 7

    40 14 9 16 5

  • 118

  • 119

    Conventions: +∞ omitted; no flow value means flow is 0.

    Iteration 1:

    45 20 30 30

    35 8 6 10 9 0

    50 9 12 13 7 0

    40 14 9 16 5 0

    8 6 10 5

    35

    40

    45

    30

    20

    s t 30

    50

  • 120

  • 121

    Iteration 2:

    45 20 30 30

    35 8 6 10 9 – ½

    50 9 12 13 7 ½

    40 14 9 16 5 ½

    8.5 6.5 10.5 4.5

    35

    40

    45

    30

    20

    s t 30

    50

  • 122

  • 123

    45 20 30 30

    35 8 6 10 9 – 1.5

    50 9 12 13 7 1.5

    40 14 9 16 5 1.5

    7.5 7.5 11.5 3.5

    Optimal transportation plan:

    45 20 30 30

    35

    50

    40

    Total cost:

    35

    40

    45

    30

    20

    s t 30

    50

  • 124

  • 125

    2.3 Introduction to the Theory of Matroids

    2.3.1 Undirected graphs

    G = (V, E) is called an undirected graph (shortly

    graph) if

    • V ≠ Ø is a finite set (set of nodes/vertices)

    • E ⊆ {{u, v}; u, v∈V, u ≠ v} (set of arcs/edges)

    We denote {u, v} by uv. Clearly, uv = vu.

    Usually: V = {v1, … ,vm}, V = m

    E = {e1, … , en}, E = n

    Let G′ = (V′, E′) and G = (V, E) be graphs.

    G′ is called a subgraph of G (notation G′ ⊆ G)

    if V′ ⊆ V and E′ ⊆ E. G′ is called proper if

    G′ ⊆ G but G′ ≠ G.

    If E = {{u, v}; u, v ∈V, u ≠ v} then G is called

    complete, notation Km:

    In every graph: 0 ≤ n ≤ 2

    1m(m – 1)

    K1 K2 K3

  • 126

  • 127

    V = V(G), E = E(G)

    p = (v0, v1, … , vk) is a walk (in G) if

    • v0, v1, … , vk ∈ V

    • vi–1vi ∈E (i = 1, 2, …, k)

    If, moreover

    • vi ≠ vj (i ≠ j; i, j = 0, 1, …, k)

    then p is called a path.

    p is a “u-v path” if v0 = u and vk = v;

    p “passes” through v0, v1, … , vk;

    p “contains” v0, v1, … , vk;

    v is “reachable” from u if there is a u-v path

    c = (v0, v1, … , vk) is a closed walk (in G) if

    c is a walk and v0 = vk.

    If, moreover, (v0, v1, … , vk–1) is a path in G

    and k ≥ 3 then c is called a cycle.

    Hamilton cycle of G … cycle that contains all

    nodes of G

    deg(v) …the number of arcs incident with v

  • 128

  • 129

    A graph G = (V, E) is called

    • acyclic (or forest) if there is no cycle in G;

    • connected if there is a u-v path in G for all

    u, v ∈ V(G);

    • a tree if G is both acyclic and connected.

    acyclic but not connected connected but not acyclic tree (m = 9, n = 8)

  • 130

  • 131

    Theorem 2.3.1 If G is a tree then n = m – 1.

    Proof: By induction on m.

    Lemma (obvious): G acyclic ⇒ every subgraph

    of G is acyclic.

    Graph H is called a (connected) component of

    the graph G if

    • H ⊆ G

    • H is connected

    • H ⊆ H′, H′⊆ G, H′ connected ⇒ H = H′

    p(G) ….. number of components of the graph G

    is not is not p(G) = 2

    is a component

    Every component of a forest is a tree.

    G

  • 132

  • 133

    Theorem 2.3.2

    If G is acyclic then n = m – p(G).

    Proof: Consider the components of G:

    1 2 3 p m1–n1=1 m2–n2=1 m3–n3=1 ……… mp–np=1

    Let G be a connected graph. Then a subgraph

    T of the graph G is called a spanning tree of G

    if

    • T is a tree

    • V(T) = V(G) (“T is spanning G”)

    (∴ Every spanning tree of a graph with m

    nodes has …….(?) arcs.)

  • 134

  • 135

    F … maximal acyclic subgraph (MAS) of G, if F

    is an acyclic subgraph of G, and F is not a

    proper subgraph of any acyclic subgraph of G.

    Theorem 2.3.3 Let G be a connected graph with

    m nodes. Then every MAS F of G is a spanning

    tree of G and hence has m – 1 arcs.

    Proof: →→→

    Graph F is a spanning forest of the graph G if

    V(F) = V(G) (let us denote this number by m)

    and each component of F is a spanning tree of

    the corresponding component of G.

    Hence p(G) = p(F) = p and so by Theorem 2.3.2

    |E(F)| = m – p.

    Corollary of Theorem 2.3.3: Let G be a graph

    with m nodes and p components. Then every

    maximal acyclic subgraph of G is a spanning

    forest of G and therefore has m – p arcs.

  • 136

  • 137

    2.3.2 The greedy algorithm

    GREEDY: Repeatedly select a most attractive

    feasible element until there are no feasible

    elements any more.

    The assignment problem (AP): Given an m × m

    matrix A, find m entries in A, no two from the

    same row or column so that their sum is

    minimal.

    If

    =

    53

    21A then GREEDY selects 1+ 5 but

    2 + 3 is minimal. Thus GREEDY is not a

    correct solution method for AP.

    The shortest path problem (SPP):

    GREEDY selects 2 + 3 but 4 is minimal.

    Thus GREEDY is not a correct solution method

    for SPP.

    s

    a

    t

    2 3

    4

  • 138

  • 139

    The Minimal Spanning Tree Problem (MST)

    Given a connected graph G = (V, E) and a

    function w: E → R, find a spanning tree

    T = (V, E*) of G such that

    ∑∈

    =*

    )(*)(Ee

    ewEw

    is minimal.

    MST is solvable by GREEDY - this will follow

    from the conversion of MST to MWF:

    The Maximum Weight Forest Problem (MWF)

    Given a graph G = (V, E) and a function

    w: E → R+, find a forest F = (V, E*) of G such

    that

    ∑∈

    =*

    )(*)(Ee

    ewEw

    is maximal (note that w(∅) = 0).

    For the conversion see Problem Sheet 4.

    Is MWF solvable by GREEDY? See matroids

    (below).

  • 140

  • 141

    2.3.3 Independence systems and matroids

    Aim: To characterise combinatorial

    optimisation problems that are solvable by

    GREEDY.

    S = (X,F ) is an independence system (IS) if

    (1) X is a finite set (called the ground set), and

    (2) F is a collection of subsets of X closed

    under inclusion, that is A∈F , A′ ⊆ A ⇒ A′∈F

    A∈F …… A is called an independent set

  • 142

  • 143

    Four examples of independence systems:

    Let G = (V, E) be a graph.

    • S1 = (E, A) is an independence system where

    A = { A ⊆ E; (V, A) acyclic}.

    Proof : Immediate by “Obvious Lemma”.

    Consider

    Then

    V = {a, b, c}, E = {ab, bc, ac},

    A = {Ø,{ab},{bc},{ac},{ab, bc},{ab, ac},{bc, ac}}=

    = 2E – {E}.

    (E, A) is an instance of S1

    a

    b c

  • 144

  • 145

    A bit more of graph theory:

    (will be needed for S2)

    Let G = (V, E) be a graph.

    M ⊆ E is called a matching if e ∩ f = Ø for all

    e, f ∈M, e ≠ f.

    Thus |M| ≤ 2

    1 m for every matching M.

    Ø is always a matching.

    {e} is always a matching.

    If |M| = 2

    1m then M is called perfect.

  • 146

  • 147

    If M is a matching in G and M is not a

    proper subset of any other matching in G then

    M is called maximal (“it cannot be extended to a

    bigger one”).

    If M is a matching in G of biggest size then M

    is called maximum.

    (In the figures below M is formed by bold arcs.)

    The difference between the size of a maximum

    matching and 2

    1 m can be arbitrarily big.

    G Not a

    matching

    Matching but not maximal

    Maximal but not maximum

    Maximum and

    perfect

  • 148

  • 149

    Let G = (V, E) be a graph.

    • S2 = (E, M) is an independence system where

    M = {M ⊆ E; M is a matching}

    Proof : →→→

    Consider

    V = {a, b, c, d}, E = {ab, bd, dc, ca},

    M = {Ø, {ab}, {bd}, {dc}, {ac}, {ab, cd}, {ac, bd}}

    (E, M) is an instance of S2.

    Note:

    For the graph above set

    F = {Ø, {ab}, {ac}, {ab, ac}}.

    (E, F ) is an independence system (different

    from S1 and S2).

    Proof: →→→

    a

    b d

    c

  • 150

  • 151

    • S3 = (E, I) is an independence system where

    E = {(i, j); i, j = 1, …, m} (the set of all

    positions in an m × m matrix) and I∈ I if

    and only if I is a set of positions such that no

    two are from the same row or column.

    Proof: →→→

    Consider

    A =

    2221

    1211

    aa

    aa

    E = {(1, 1), (1, 2), (2, 1), (2, 2)}

    I = {Ø,

    {(1, 1)}, {(1, 2)}, {(2, 1)}, {(2, 2)},

    {(1, 1), (2, 2)}, {(1, 2), (2, 1)}}

    (E, I) is an instance of S3.

  • 152

  • 153

    • S4 = (C, L) is an independence system where

    C = {1, …, n} (the set of column indices of an

    m × n matrix) and

    L = {J ⊆ C; columns with indices from J are

    linearly independent}.

    Proof: →→→

    Consider

    =

    00110

    02101A

    C = {1, 2, 3, 4, 5}

    L = {Ø, {1}, {2}, {3}, {4}, {1, 2}, {1, 3}, {2, 3},

    {2, 4}, {3, 4}}

    (C, L) is an instance of S4.

  • 154

  • 155

    Upper bounds for the sizes of independent sets:

    S1: |A| ≤ m – p

    S2: |M| ≤ 2

    1 m

    S3: |I| ≤ m

    S4: |J| ≤ rank of A ≤ min(m, n)

    “Independent” means:

    S1: acyclic (graph)

    S2: matching (in a graph)

    S3: independent (positions in a matrix)

    S4: linearly independent (vectors)

  • 156

  • 157

    Let S = (E, F ) be an independence system. The

    combinatorial optimisation problem (COP)

    associated with S, notation (S, w), is:

    Given a weight function w: E → R+, find an

    independent set (called an optimal solution) that

    has the biggest total weight, i.e. find X*∈F such

    that

    w(X*) = )(max XwX F∈

    where w(X) = ∑∈Xe

    ew )( for X ⊆ E.

    COP associated with S1:

    Given a graph G = (V, E) and w: E → R+, find

    an acyclic subgraph of G of maximal total

    weight [= Maximum Weight Forest Problem].

    COP associated with S3:

    Given an m × m matrix A = (aij) ≥ 0, find m

    entries in A, no two either from the same row or

    column, of maximal total value [= Assignment

    Problem].

  • 158

  • 159

    THE GREEDY ALGORITHM (GREEDY)

    Input: Independence system S = (E, F ),

    w: E → R+.

    Output: X* ∈F for which w(X*) is maximal.

    (1) X* := Ø

    (2) (“Find the most attractive element in E”)

    Find e ∈ E such that w(e) = )z(wmaxEz∈

    (3) E := E – {e}

    (4) (“Check feasibility”)

    If X* ∪ {e} ∈F then X* := X* ∪ {e}

    (5) If E = Ø then stop else go to (2)

  • 160

  • 161

    Theorem 2.3.4 Let S = (E, F ) be an

    independence system. Then the following

    statements are equivalent:

    (A) For every w: E → R+ GREEDY correctly

    solves (S, w).

    (B) [Exchange Proposition (EP)]

    For all F, F′∈F, if |F′| = |F| + 1 then there

    is e ∈ F′ – F such that F ∪ {e} ∈ F.

    (C) [Rank Proposition (RP)]

    If A ⊆ E and F, F′ are maximal

    independent subsets of A then |F| = |F′|.

    An independence system satisfying one (and

    therefore all) of the conditions (A), (B), (C) in

    Theorem 2.4.4 is called a matroid.

  • 162

  • 163

    Let S = (E, F ) be a matroid. The (common) size

    of maximal independent subsets of a set A ⊆ E

    is called the rank of A and any maximal

    independent subset of A is called a basis of A.

    A minimal dependent subset of E (that is a

    dependent set whose every proper subset is

    independent) is called a circuit.

    • S1 = (E, A) is a matroid:

    Use RP: Let A ⊆ E be fixed and take F ⊆ A.

    F is an independent subset of A if and only if

    (V, F) is an acyclic subgraph of GA = (V, A).

    ∴F is a maximal independent subset of A if

    and only if (V, F) is a maximal acyclic

    subgraph of GA = (V, A).

    ∴ |F| = m – p(GA) (Cor. to Theorem 2.3.3)

    ∴ S1 is a matroid (notation Gr(G)).

    Hence: GREEDY correctly solves every instance

    of MWF and, in particular, the MST.

  • 164

  • 165

    • S2 = (E, M ) is not a matroid:

    A = {ac, ab, bd}

    {ac,bd},{ab} – maximal independent subsets of A

    ∴ GREEDY does not always solve the maximal

    weighted matching problem correctly.

    • S3 = (E, I ) is not a matroid:

    2221

    1211

    aa

    aa

    A = { (1, 1), (1, 2), (2, 1)}

    {(1, 2), (2, 1)}, {(1, 1)} – maximal independent

    subsets of A

    ∴ GREEDY does not always solve AP correctly.

    • S4 is a matroid.

    Proof: →→→

    a

    b d

    c

  • 166

  • 167

    K = is called a field if the following

    axioms hold:

    a + b = b + a a.b = b.a

    a + (b + c) = (a + b) + c a.(b.c) = (a.b).c

    a .(b + c) = a.b + a.c

    (∃0∈K) a + 0 = a (∃1∈K) a.1 = a

    (∀a∈K)(∃–a∈K) a + (–a) = 0

    (∀a∈K, a ≠ 0)(∃a-1∈K) a.a-1 = 1

    Vectors, matrices, linear (in)dependence.

    col (A) ….. the set of column indices of A

    Let A be an m × n matrix over K and

    LA = { X ⊆ col(A); columns of A with indices

    from X are linearly independent}.

    Then (col(A), LA) is a matroid. Notation M(A).

    S4 is M(A) for K = R.

  • 168

  • 169

    Independence systems S = (E, F ) and

    S′ = (E′, F ′ ) are called isomorphic (notation

    S ≈ S’) if a bijection φ: E → E′ exists such that

    F ∈F ⇔ φ(F) ∈F ′

    where φ(F) = {φ(x); x ∈F }.

    A matroid S is called matric if S ≈ M(A) for

    some field K = and for some matrix

    A over K.

    A matroid S is called graphic if S ≈ S1 for some

    graph G = (V, E). Notation Gr(G).

    Theorem 2.3.5 Every graphic matroid is matric.

    Notes:

    • Not every matric matroid is graphic.

    • Not every matroid is matric.

  • 170

  • 171

    Graphic

    matroids

    Matric matroids

    Matroids

    Independence systems

    GREEDY works

    GREEDY does not work

  • 172

  • 173

    3 Hard problems

    3.1 On the NP -completeness

    3.1.1 Why “efficient” means “polynomial”

    Computer speed: 10 GHz (1010 ops/sec)

    Running times of algorithms

    Size of input

    No of ops

    20 60 … 100 1000

    L 0.002µs 0.006µs … 0.01µs 0.1µs

    L2 0.04µs 0.36µs … 1µs 0.1ms

    L4 16µs 1.296ms … 10ms 100s

    2L 0.1ms 3yrs … 1012yrs .

    L! 7.7yrs . … . .

    L … the size of input

    f(L) … number of operations required for

    instances of size L in the worst case

  • 174

  • 175

    Today (within a time limit): size 100

    Computer speed increase: 1000-times

    Within the same time limit:

    No of ops Size

    L 100,000

    L2 3,162

    L4 562

    2L 109

    L! 101

    Informally: A method for solving a problem Q

    is called polynomial if f(L) ≤ p(L) for some

    polynomial p.

  • 176

  • 177

    3.1.2 Examples of hard problems

    • HAM - Existence of a Hamiltonian cycle:

    A cycle in a graph G = (V, E) is called

    Hamiltonian (or a tour) if it contains all nodes of

    G and G is called Hamiltonian if it contains a

    Hamiltonian cycle.

    HAM: Given a graph, is it Hamiltonian?

    No polynomial method is known.

    Similarly for digraphs.

    • TSP – The Travelling Salesman Problem

    Given a complete arc-weighted graph/

    digraph, find a tour of minimal total length.

    No polynomial method is known.

    Hamiltonian graph

    Hamiltonian graph

    Non-Hamiltonian graph

  • 178

  • 179

    • INTEGER LP (ILP)

    Given an integer matrix A, integer vectors b, c,

    find an integer vector x which solves the

    optimisation problem

    cTx → min

    Ax = b

    x ≥ 0

    No polynomial method is known.

    • (INTEGER) KNAPSACK

    ILP is hard even if it contains only one equation

    and only feasibility is wanted:

    Given integers a1, …, an and K, are there

    integers x1, …, xn ≥ 0 such that

    Kxan

    jjj =∑

    =1 ?

    An important variant: 0-1 KNAPSACK:

    Given integers a1, …, an and K, is there a

    subset S of {1, …, n} such that KaSj

    j =∑∈

    ?

    No polynomial method is known for either.

  • 180

  • 181

    3.1.3 NP -complete problems

    Class P : The class of all polynomially solvable

    problems.

    Class NP : The class of problems where an

    object can be verified to be a solution in

    polynomial time. This is a very wide class of CO

    problems containing all “reasonable” problems

    (including those for which a polynomial solution

    method is not known and those which are

    polynomially solvable).

    ThusP ⊆NP.

    Conjecture: P ≠ NP

  • 182

  • 183

    Q ∈NP is called NP – complete if it satisfies the

    following:

    If Q ∈ P then P = NP .

    Class NPC : The class of NP – complete

    problems. Thus, if Q ∈NPC then Q is very

    unlikely to be polynomially solvable.

    Examples of NP – complete problems:

    HAM, TSP, ILP, KNAPSACK, 0-1 KNAPSACK

    Examples of problems in P : LP, MFP, SPP, AP

    NPC

    P

    NP

  • 184

  • 185

    Two special cases of the TSP:

    TSP is metric (notation ∆TSP) if the direct-

    distances matrix A = (aij) satisfies the triangle

    inequality, that is aik + akj ≥ aij for all i, j, k.

    Metric:

    Not metric:

    3

    2

    1 4

    2

    3

    a b

    c d

    3

    2

    1 4

    5

    7

    a b

    c d

  • 186

  • 187

    “Distance” may have various meanings:

    geographical distance, time, cost…

    TSP is Euclidean if the direct-distances matrix

    A = (aij) is the matrix of Euclidean distances

    between points in a plane with the Cartesian

    coordinate system.

    aij = d(zi, zj) for all i, j

    where for a = (x1, y1), b = (x2, y2)

    d(a, b) = ( ) ( )221

    2

    21yyxx −+−

    (Euclidean distance)

    x

    y z1

    z2

    z4 z3

  • 188

  • 189

    Hence every Euclidean TSP is ∆TSP.

    Further NP – complete problems:

    ∆TSP

    Euclidean TSP

    Remark: The hardness of two similar problems

    may be very different. Pairs of closely related

    problems of profoundly different hardness:

    In P In NPC

    LP

    AP

    AP

    MINCUT

    SEPP (≥ 0)

    ILP

    3AP

    TSP

    MAXCUT

    LEPP (≥ 0)

    Our final aim: To design approximate

    algorithms for the ∆TSP.

  • 190

  • 191

    3.2. Algorithms for NP -complete Problems

    3.2.1 Approximation algorithms - introduction

    In order to measure the quality of an algorithm

    we define the relative error of an algorithm:

    Q … a combinatorial optimisation problem

    (minimisation)

    inst(Q) … the set of all instances of Q

    c > 0 … cost function on the set of feasible

    solutions of an instance

    A … an algorithm: I∈inst(Q) → f(I) (a

    feasible solution)

    c(f(I)) … the cost of f(I)

    c*(I) … optimal cost value for I∈inst(Q)

    re(A , I) )I(*c

    )I(*c))I(f(cdef −= … the relative error

    of A with respect to instance I. Let ε ≥ 0. Then

    an algorithm A for solving Q is called ε-

    approximate if re(A , I) ≤ ε for all instances I.

  • 192

  • 193

    3.2.2 Multigraphs and Eulerian spanning graphs

    Multigraph is a diagram that can be obtained

    from an undirected graph by adding a

    nonnegative number of parallel edges.

    A walk in a multigraph is a sequence of nodes

    and arcs: (v1, e1, v2, e2, …, vk) where each ei is

    an arc with endpoints vi and vi+1 (i = 1, …, k-1).

    If v1 = vk then the walk is called closed.

    Eulerian walk in a multigraph is a walk

    (1) which is closed,

    (2) in which every node appears at least once

    and

    (3) in which every arc appears exactly once.

  • 194

  • 195

    (v1, f8, v4) … not a walk

    w = (v1, f1, v2, f2, v1, f3, v2, f4, v1, f6, v4, f8, v2, f7, v3, f5, v1)

    w … Eulerian walk (EW)

    A multigraph G is called Eulerian if there is an

    Eulerian walk in G.

    v1 v2

    v3 v4

    f1 f2

    f3

    f4 f6 f7 f5 f8

    walk but not closed

    closed walk but not Eulerian

  • 196

  • 197

    Theorem 3.2.1 (Euler): A multigraph G = (V, E)

    is Eulerian ⇔

    (1) G is connected and

    (2) The degree of every node is even.

    Sketch of proof →→→

    Note: If G is Eulerian then an Eulerian walk in

    G can easily be found.

    Our aim is to find a good approximation of a

    solution to TSP, that is a tour whose length is

    close to the minimal length.

    But how to construct a tour from an Eulerian

    walk?

    We will see two ways of doing this, leading to

    two algorithms: TREE and Christofides’.

    Note that a TSP for can be given in two

    equivalent ways:

    By a symmetric matrix A = (aij) ∈ Rn×n or by a

    complete arc-weighted graph (Kn, (aij)).

    A … direct-distances matrix

  • 198

  • 199

    A common tool for both algorithms is the

    concept of an Eulerian spanning graph:

    Let A = (aij) be a symmetric n × n matrix with

    zero diagonal. An Eulerian spanning graph of A

    (ESG) is any Eulerian multigraph G = (V, E)

    with V = {1, …, n}. The cost of G is

    c(G) = ∑∈Eji

    ija),(

    .

    Hence c(G) = the cost of any Eulerian walk in G.

    The two algorithms differ by the construction of

    the ESG. But once we have an ESG we construct

    a tour, called embedded tour, from any Eulerian

    walk w in the ESG in a unique way:

    Start from the first node in w and then

    repeatedly take the first node in w that has not

    been taken yet. At the end we add the first node.

    (See the example on the next page)

  • 200

  • 201

    w = (v1, e1, v2, e2, v1, e7, v4, e6, v3, e3, v2, e4, v3, e5, v1)

    Embedded tour τ =

    c(τ) =

    v1 v2

    v3 v4

    e2

    e7 e5 e4

    e3

    e6

    e1

  • 202

  • 203

    3.2.3 Approximation algorithms for ∆TSP

    Convention: We will draw only arcs of Kn that

    are needed.

    Theorem 3.2.2 Let (Kn, (aij)) be an instance of

    ∆TSP for a symmetric matrix A = (aij). If

    G = (V, E) is an Eulerian spanning graph for

    A = (aij) then every tour in Kn embedded in an

    Eulerian walk in G has length not exceeding the

    cost of G.

    Proof: →→→

  • 204

    e1

  • 205

    TREE ALGORITHM

    Input: ∆TSP given by an n × n symmetric

    direct-distances matrix A = (aij) ≥ 0

    Output: A tour in Kn

    (1) Find an MST T in (Kn, (aij)) (note: we may

    use GREEDY!)

    (2) Create a multigraph G = (V, E) by using

    two copies of each edge of T.

    (3) Find an Eulerian walk w in G and a tour

    embedded in w.

    Note: G is an ESG since it is connected and

    every node has an even degree.

    Theorem 3.2.3 TREE ALGORITHM is a 1-

    approximate algorithm for ∆TSP.

    Proof: →→→

  • 206

  • 207

    Lemma (to the next theorem):

    The number of nodes of odd degree in any

    graph is even.

    Proof: →→→

    CHRISTOFIDES’ ALGORITHM (CA)

    Input/Output: As TREE ALGORITHM

    (1) Find an MST T in (Kn, (aij)).

    (2) Take the nodes of odd degrees in T and

    find a perfect matching M of minimal total

    weight in the complete graph induced by

    these nodes. Let G be the multigraph with

    arcs from T and in M (note: G is an ESG

    by the Lemma!).

    (3) Find an Eulerian walk w of G and a tour

    embedded in w.

    Theorem 3.2.4 CA is a 2

    1- approximate

    algorithm for ∆TSP.

    Remark: Average error = 19.5%.

  • 208

  • 209

    Proof of Theorem: →→→

    Illustration to the proof:

    i8

    i7

    i6

    i5

    i4

    i3

    i2 i1

    τ*

  • 210