introduction to linear programming and game theory

8
5/25/2018 IntroductiontoLinearProgrammingandGameTheory-slidepdf.com http://slidepdf.com/reader/full/introduction-to-linear-programming-and-game-theory IB104 - Mathematical Programming I D. Wilson-Nunn [email protected] Summer Term 2013 Formulation When forming a linear programming problem, we need to identify three things: 1. Decision variables - the thing that you are changing, e.g. kilogrammes of products A, B & C 2. Objective function - a function of your decision variables that you want to maximise or minimise, e.g. profit, costs etc. 3. Constraints - the limits on what you can make or ship, e.g. one lorry can only hold a certain number of chairs Once we have identified these things, we can write out our linear programming problem. This can be done in two ways, either as standard maths, or using matrices and vectors. Maximise   n i=1  c i x i  =  z Subject to   n j=1  a ij x j  ≤ b i ,  ∀i x k  ≥  0,  ∀k ∈  K  ⊆ {1,...,n} Maximise  c.x = z Subject to  A.x  b x ≥  0 In matrix form, we have  c  = c 1  ···  c n ,  x = x 1  ···  x n ,  b  = b 1  ···  b m ,  A  = a 11  ···  a 1n .  ...  . a m1  ···  a mn We often need to use the standard (augmented) form of a linear programming problem, this can be thought of as Maximise z  : 1  −c 0 0 A I · z x x s =  0 b x, x s  ≥  0 Where  x s  is the vector of slack/excess variables. Also, note that the matrix  I  can have either positive values or negative values along its leading diagonal, depending on whether the entry represents a slack or excess variable. Solving Solving a linear programming problem can either be done graphically if there are two decision variables (or the dual has two decision variables), or using the simplex algorithm. Graphical Solving There are a few steps to graphically solving a linear programming problem 1. Plot all the inequalities taking  x 1  to be one axis, and  x 2  to be the other  An easy way to do this, given an inequality  ax 1  +  bx 2  ≤ c  is by setting  x 1  and  x 2  separately equal to 0, and finding where the line intersects each axis. 2. Shade or identify the area that satisfies all the inequalities 1

Upload: daniel-wilson-nunn

Post on 15-Oct-2015

32 views

Category:

Documents


1 download

DESCRIPTION

A short document talking through some of the major principles in basic Linear Programming and Game Theory.

TRANSCRIPT

  • IB104 - Mathematical Programming I

    D. Wilson-Nunn

    [email protected]

    Summer Term 2013

    Formulation

    When forming a linear programming problem, we need to identify three things:

    1. Decision variables - the thing that you are changing, e.g. kilogrammes of products A, B & C2. Objective function - a function of your decision variables that you want to maximise or minimise, e.g. profit,

    costs etc.3. Constraints - the limits on what you can make or ship, e.g. one lorry can only hold a certain number of chairs

    Once we have identified these things, we can write out our linear programming problem. This can be done in twoways, either as standard maths, or using matrices and vectors.

    Maximiseni=1 cixi = z

    Subject tonj=1 aijxj bi, i

    xk 0, k K {1, . . . , n}

    Maximise c.x = zSubject to A.x b

    x 0

    In matrix form, we have c =[c1 cn

    ], x =

    [x1 xn

    ], b =

    [b1 bm

    ], A =

    a11 a1n...

    . . ....

    am1 amn

    We often need to use the standard (augmented) form of a linear programming problem, this can be thought of as

    Maximise z :[1 c 00 A I

    ]

    zxxs

    =[

    0

    b

    ]

    x,xs 0

    Where xs is the vector of slack/excess variables. Also, note that the matrix I can have either positive values ornegative values along its leading diagonal, depending on whether the entry represents a slack or excess variable.

    Solving

    Solving a linear programming problem can either be done graphically if there are two decision variables (or the dualhas two decision variables), or using the simplex algorithm.

    Graphical Solving

    There are a few steps to graphically solving a linear programming problem

    1. Plot all the inequalities taking x1 to be one axis, and x2 to be the other

    An easy way to do this, given an inequality ax1 + bx2 c is by setting x1 and x2 separately equal to 0,and finding where the line intersects each axis.

    2. Shade or identify the area that satisfies all the inequalities

    1

  • 3. Determine the direction in which the objective function travels, and then find the corner of the shaded regionthat either maximises or minimises the objective function

    4. The coordinates of this corner are the values of x1, x2 that optimise the objective function subject to theconditions given.

    If using the dual method, then you will then have to use Complementary Slackness to find the values of thedecision variables in the primal.

    Simplex Algorithm

    This is a simple algorithm, that when these steps are followed, will result in an optimal solution to most linearprogramming problems. It is important to note that simplex is for maximisation. To solve a minimisation problem,notice that min {z} = max {z}Step 0 Put the linear programming problem in standard form, as above, and then form a tableau of this like so

    0 1 n n+1 n+m

    z x1 xn s1 sm RHS0 1 c1 cn 0 0 01 0 a11 a1n 1 0 b1...

    ......

    . . ....

    .... . .

    ......

    m 0 am1 amn 0 1 bm

    Step 1 If cj 0,j, stop; the current basic feasible solution is optimal.Step 2 Select q such that min

    1in+mci = cq to determine which non-basic variable is to become basic.

    Step 3 Calculate the ratios bi/aiq for aiq 6= 0, i = 1, 2, . . . ,m, then select p such that

    bpapq

    = min1im

    {biaiq

    aiq 6= 0, biaiq 0}

    Step 4 Perform elementary row operations using the p-th row to make the pq-th element 1 and all other elements inthe q-th column equal to 1. Return to Step 1.

    Note: ci refers to the element in row 0, column i at the current point in time, whereas ci refers to the initial valueof that element.

    When you have exited the algorithm, you will be left with a number of basic variables and non-basic variables. Basicvariables are those whose columns in the final simplex tableau consist of one 1 and many 0s. The basic variables arethe ones that constitute the optimal solution. For each basic variable, read directly along the i-th row where the 1is at element aij to the RHS column and this is the value of the variable in the j-th column. Set the value of eachnon-basic variable to 0.

    Duality

    The basic idea of duality can be seen by simply looking at a primal and its associated dual

    Primal()

    Dual()

    Maximisenj=1 cjxj = z

    Subject tonj=1 aijxj bi

    xk 0

    Minimisemi=1 biyi = v

    Subject tomi=1 aijyi cj

    yk 0

    Maximise c.x = zSubject to A.x b

    x 0

    Minimise b.y = vSubject to A.y c

    y 0

    Where y =[y1 yn

    ], and the others are as before.

    When forming the dual, it is important to make sure that the linear programming problem is in normal form first.This means that the following conditions hold

  • Maximise Minimise

    All constraints must be All constraints must be All variables must be 0 All variables must be 0

    To convert to normal form, the following tricks are very useful:

    Original condition (for maximisation) How to make normal

    Constraint of the form a1jx1 + + anjxn bj Multiply by 1 to get a1jx1 anjxn bjConstraint of the form a1jx1 + + anjxn = bj Replace with a1jx1 + + anjxn bj

    and a1jx1 anjxn bjVariable xi unrestricted in sign Replace xi with x

    i xi where xi, xi 0

    Original condition (for minimisation) How to make normal

    Constraint of the form a1jx1 + + anjxn bj Multiply by 1 to get a1jx1 anjxn bjConstraint of the form a1jx1 + + anjxn = bj Replace with a1jx1 + + anjxn bj

    and a1jx1 anjxn bjVariable xi unrestricted in sign Replace xi with x

    i xi where xi, xi 0

    Complementary Slackness

    Sometimes it is easier to find a solution to the dual than the primal. If this is the case and having solved thedual, we have found y1, . . . , ym, we will need to find the values of x1, . . . , xn. This can be done using the notion ofcomplementary slackness and the strong duality property.

    Strong Duality Property If the primal problem has a finite optimal solution, then so does the dual problem, andthese two values are equal. That is to say if z is the optimal solution to the primal problem, and v is the optimalsolution to the dual problem, then z = v.

    Complementary Slackness If the primal problem has a finite optimal solution, x1, . . . , xn, then the solution to thedual y1, . . . , ym can be found using the following relation n

    j=1

    aij xj bi yi = 0, i {1, . . . ,m}

    and consequently, if the dual has a finite optimal solution, y1, . . . , ym, then the solution to the dual x1, . . . , xncan be found using the following relation m

    i=1

    aij yi cj xj = 0, j {1, . . . , n}

    Simply put;

    1. In the solution to the dual, if constraint i is binding, then in the primal, variable xi is non-zero2. In the solution to the dual, if constraint i is not binding, then in the primal, variable xi = 03. In the solution to the dual, if variable yi is non-zero, then in the primal, constraint i is binding4. In the solution to the dual, if variable yi = 0, then in the primal, constraint i is not binding

    Sensitivity Analysis

    Sensitivity analysis is all about working out how much the price or availability of resources can change for our solutionto still remain optimal.

    Objective Function Sensitivity

    If we wish to see how much the value of cj (the coefficient of xj in the objective function) can be changed (i.e. tocj + ) without changing the optimal solution, there are some simple steps to follow

    Step 1 Carry out the simplex algorithm as normal to find the optimal solutionStep 2 When you have the final tableau, replace cj with cj .

  • If cj 6= 0 then the solution to how much cj can be changed can be found using cj 0. Stop here.Else We are left with in the j-th position in row 0. As we cant have negative values in row 0, add times row

    i to row 0, where i is such that aij = 1. Now we have that row 0 contains ck+aik, k 6= j and cj in columnj. We solve ck + aik 0, k 6= j, and then find the interval (c, d) such that (c, d) ck + aik 0,k 6= j

    Constraint Sensitivity

    If we wish to find how much we can change the value of bi (i.e. to bi+), such that our current solution is still optimal,then again we follow some simple steps

    Step 1 Carry out the simplex algorithm as normal to find the optimal solutionStep 2 When you have the final tableau, replace bk with bk + bki. Where bki are the entries in the (n+ i)-th column

    of the final simplex tableau.Step 3 Solve bk + bki 0, k, and hence find an interval (c, d) such that (c, d) bk + bki 0, k

    Transportation Problems

    When we have m supply nodes and n demand nodes, each with supply/demand constraints s =[s1 sm

    ],

    d =[d1 dn

    ]and a cost/profit matrix C =

    (cij)

    where cij is the cost/profit associated with transporting one

    unit from supply node i to demand node j. We need to find the optimal delivery matrix X =(xij)

    where xij is thenumber of units shipped from supply node i to demand node j, such that

    Max/Minmi=1

    nj=1 cijxij = z

    Subject tonj=1 xij = si, imi=1 xij = dj , j

    xij 0

    Note that our algorithm is for minimisation, and as such, if you wish to maximise (profit for example), then use thesame trick as before, min {z} = max {z} (multiply by 1). Also note that we can only find feasible solutions totransportation problems if

    mi=1 si =

    nj=1 dj . If this is not an equality, we can make it so

    If mi=1 si nj=1 dj = ` > 0, then add an extra demand node with demand ` and shipping cost 0. If mi=1 si nj=1 dj = l < 0, then there is no feasible solution to the problem, and penalties have to be

    introduced to solve the problem. They should be given in the question.

    Assign each demand node a penalty cost, that is charged for each unit deficit from the demand Introduce a new dummy supply node with supply l units The cost of shipping per unit from this dummy supply node to demand node j is the associated penalty

    cost for node j.

    We now need to find a feasible solution to the problem, we can do this in two ways, either the Northwest CornerMethod, or the Minimum Cost Method. For both methods, we must first create a table of the form below, this iscalled a supply schedule.

    v1 vj vn

    u1c11 c1j c1n

    s1x11 x1j x1n

    uici1 cij cin

    sixi1 xij xin

    umcm1 cmj cmn

    smxm1 xmj xmn

    d1 dj dn

    Now we can go about finding basic feasible solutions, first we will do the Northwest Corner Method

    Step 1 Allocate the maximum amount allowable by the supply and demand constraints to the variable x11

  • Step 2 If a column or row is satisfied, cross it out. The remaining decision variables are set equal to zero. If a rowand column are satisfied simultaneously, cross only one out and it doesnt matter which.

    Step 3 Adjust supply and demand for the non-crossed out rows and columns.Step 4 Allocate the maximum feasible amount to the first available non-crossed out element in the next row/column.Step 5 When exactly one row or column is left, all the remaining variables are basic and are assigned the only feasible

    allocation.

    Now we move onto the Minimum Cost Method,

    Step 1 Assign as much as possible to the cell with the smallest unit cost in the entire tableau. If there is a tie thenchoose arbitrarily.

    Step 2 Cross out the row or column which has satisfied supply or demand. If a row and column are both satisfiedthen cross out only one of them, choosing the row or column to delete with the largest values of cij .

    Step 3 Adjust the supply and demand for those rows and columns which are not crossed out.Step 4 When exactly one row or column is left, all the remaining variables are basic and are assigned the only feasible

    allocation.

    Having found a feasible solution, we now need to optimise it. To do this, we will follow another algorithm, theTransportation Simplex Algorithm.

    Step 1 If problem is unbalanced, balance it.Step 2 Use Northwest Corner Method or Minimum Cost Method to find a basic feasible solution.Step 3 For every xij 6= 0, set ui + vj = cij , using the starting condition u1 = 0. These are the shadow prices.Step 4 If ui + vj cij 0, i, j then the current solution is optimal, you can stop here. Else, follow the following

    procedure.

    Step 4.1 Draw the current feasible solution as a network, for example:

    15

    20

    30

    20

    10

    30

    u1 = 0

    u2 = 1

    u3 = 4

    v1 = 8

    v2 = 6

    v3 = 12

    v4 = 1

    Step 4.2 As our solution is not optimal, there is at least one ij such that ui + vj cij > 0. Pick the largestui + vj cij > 0, and add an edge (i, j) with weight to the network, (taking care to ensure that no moreis delivered than can be delivered, by subtracting from other edges) and identify the loop that has beenformed. For example:

    15 +

    20 30

    20

    10

    30

    u1 = 0

    u2 = 1

    u3 = 4

    v1 = 8

    v2 = 6

    v3 = 12

    v4 = 1

    Now we find the value of as

    = max {`} such that min{xi1j1 `, xi2j2 `} = 0Step 4.3 Update the delivery schedule with the new xijStep 4.4 Return to Step 3

  • Game Theory

    In this course, we only deal with finite, zero-sum two player games. Our aim is to try and find the optimal solutionto any given game.All games that we will be given can be formatted in a matrix like so

    1 n rowmin

    1 a11 a1n min{a1j}

    ......

    . . ....

    ...

    m am1 amn min{amj

    }colmax max {ai1} max {ain}

    Where aij represents the amount transferred from player two to player one when player one plays strategy i and playertwo plays strategy j.

    Saddle Point There is a saddle point if and only if the following is true.

    min1jn

    colmax = max1im

    rowmin

    If there is a saddle point at (i, j), then player 1 should always pick strategy i and player 2 should always pick strategyj, and the value of the game is min colmax = max rowmin = v.

    General solution to 2 2 gamesLet A represent the play-off matrix for a given 2 2 game.

    A =

    [ 1 21 a b

    2 c d

    ]Then to solve this game, we do the following procedure

    1. Test for a saddle point2. If there is no saddle point, solve by finding equalising strategies

    There is no saddle point if either of the following is true

    a > b, b < d, d > c and c < a a < b, b > d, d < c, and c > a.

    We want to find the optimal value of p, say p, such that if player one uses the strategy p =[p 1 p

    ]ap + c (1 p) = bp + d (1 p)

    Solving for p, we find

    p =d c

    (a b) + (d c)Since there is no saddle point, (a b) and (d c) are either both positive or both negative; hence, 0 < p < 1. Playerones average return using this strategy is

    v = ap + c (1 p) = ad bca b+ d c

    Now, if player two uses the strategy q =[q 1 q

    ], then we have

    aq + b (1 q) = cq + d (1 q)hence,

    q =d b

    a b+ d cAgain, as there is no saddle point, 0 < q < 1. Then player twos average loss using this strategy is

    aq + b (1 q) = ad bca b+ d c = v

  • Games that arent 2 2If a game isnt 2 2, then it may be possible to make it into 2 2 form and solve using the above method, or into2 n or m 2 form, and then solve using graphical methods.

    Dominance A strategy i for player one is strictly dominated if j such that aik < ajk, k. The strategy is weaklydominated if instead of akj , k. The strategy is weakly dominated ifinstead of > we have . When a strategy i is dominated by strategy j, we can delete i as it is always better to choosej.

    Solving 2 n and m 2 gamesHaving reduced a game to 2 n or m 2 matrix, we can solve it graphically. Say we have a game

    A =

    [ 1 n1 a1 an2 b1 bn

    ]

    The player one can choose row one and row two with probabilities p and 1 p respectively. By plotting the lines

    l1 = a1p+ b1 (1 p)...

    ln = anp+ bn (1 p)

    for the interval p [0, 1], we are able to find the optimal p (i.e. p) for player one.

    There are a few steps to graphically solve a two playergame in the form 2 n

    1. Plot all the lines li2. Identify the minimal portions of all these lines

    (in thick print in the example)3. Find the maximal point throughout the whole

    of this minimal curve4. The p-coordinate for this point, it the optimal

    value of p, i.e. p.

    p

    v

    0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.00

    l1l2

    l 3

    l4

    min

    5. This value p gives a value, v, for the game6. Identify which columns are associated with this coordinate, (i.e. the intersection of lines li and lj

    involves columns i and j)7. These two columns are the only two columns involved in the game now (making it a 2 2 game), so

    solve the following for q to find the optimal q for player two.

    aiq + bi (1 q) = v

    ajq + bj (1 q) = v

    The process is similar for if we have an m 2 game, take for example the game

    B =

    1 2

    1 a1 b1...

    ......

    m am bm

  • The player two can choose column one and column two with probabilities q and 1 q respectively. By plotting thelines

    l1 = a1q + b1 (1 q)...

    ln = amq + bm (1 q)for the interval q [0, 1], we are able to find the optimal q (i.e. q) for player two.

    There are a few steps to graphically solve a two playergame in the form m 2

    1. Plot all the lines li2. Identify the maximal portions of all these lines

    (in thick print in the example)3. Find the minimal point throughout the whole

    of this maximal curve4. The q-coordinate for this point, it the optimal

    value of q, i.e. q.

    q

    v

    0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.00

    l1

    l2

    l3

    l 4

    max

    5. This value q gives a value, v, for the game6. Identify which rows are associated with this coordinate, (i.e. the intersection of lines li and lj involves

    rows i and j)7. These two rows are the only two rows involved in the game now (making it a 2 2 game), so solve

    the following for p to find the optimal p for player two.

    aip + bi (1 p) = v

    ajp + bj (1 p) = v

    Note that at times, p, (or equivalently, q), may be an interval, rather than a value.

    Irreducible m n gamesThere will be times when we are given games that cannot be reduced far enough to make them solvable with ourmethods. When we have these, we need to use linear programming to find an optimal solution. Say that we have agame A where we have reduced it as much as we can using dominance, and we are left with the play-off matrix

    A =

    1 n

    1 a11 a1n...

    .... . .

    ...

    m am1 amn

    Then for player one, we need to find a probability distribution p =

    [p1 pm

    ]that maximises the minimum gain.

    To do this, we formulate and solve the following linear programming problem.

    Maximise v

    Subject tomi=1 aijpi v, jm

    i=1 pi = 1

    pi 0, i

    To find the optimal probability distribution q, we must find the vector q =[q1 qn

    ]that minimises the

    maximum loss. To do this, we again form and solve the following linear programming problem.

    Minimise v

    Subject tonj=1 aijqj v, in

    j=1 pj = 1

    pj 0, j